Plots ColorSchemes issues

I’m trying to debug a shifty little plotting issue. Plotting gif of examples seems broken · Issue #15 · weymouth/WaterLily.jl · GitHub

The root cause seems to be inconsistent behaviour for palette() (but I might be wrong on that).

using Plots
Plots.GRBackend()

function f(x, y)
	r = sqrt(x^2 + y^2)
	return cos(r) / (1 + r)
end
x = range(0, 2π, length = 30)
pal = palette(:RdBu_11)
contour(x, x, f, fill=(true,pal))

This works fine for me from the REPL, but when I use Pluto (and it seems when the user above uses the REPL) it throws an error

MethodError: no method matching _as_gradient(::Array{ColorTypes.RGBA{Float64},1})

Closest candidates are:

_as_gradient(!Matched::PlotUtils.ColorGradient) at /Users/weymouth/.julia/packages/Plots/8GUYs/src/utils.jl:136

_as_gradient(!Matched::ColorTypes.Colorant) at /Users/weymouth/.julia/packages/Plots/8GUYs/src/utils.jl:137

Any idea how to work around this?

Not sure if this is helpful, but here’s what I get in the REPL:

julia> contour(x, x, f, fill=(true,pal))
┌ Warning: GR: filled contour only supported with black contour lines
└ @ Plots ~/.julia/packages/Plots/vVVub/src/backends/gr.jl:1808

julia> Pkg.status("Plots")
      Status `~/Julia/workspace/Project.toml`
  [91a5bcdd] Plots v1.14.0

julia> Pkg.status("GR")
      Status `~/Julia/workspace/Project.toml`
  [28b8d3ca] GR v0.57.4

And with Pluto (browser: Firefox), this:

Yes, it used to work fine in Pluto, but when I just updated this morning, it started throwing that error.

I installed Pluto specifically to run the above code, so it’s supposedly up to do date. Here’s what I have:

julia> Pkg.status("Pluto")
      Status `~/Julia/workspace/Project.toml`
  [c3e4b0f8] Pluto v0.14.5

If you ran Pkg.update(), sometimes you get a downgrade. What versions do you have?

Also 14.5. Weird!

Have you tried in a completely clean environment? Start with new Project.toml and Manifest.toml files and for good measure delete any old versions of Pluto, Plots and GR packages inside .julia/packages/ before reinstalling them. :thinking: