Using ColorSchemes

How do I import all the color schemes from ColorSchemes in one go?

Thanks.

P.S.

This code used to work before.

using Plots, Random
cs = collect(keys(colorschemes))
cp = first(Random.shuffle!(cs))
plot(x, y, palette = cp) # some x, y

Not anymore. I get this error:

ERROR: There is no gradient named isoluminant_cm_70_c39_n256 . Use cgradients() to get a list of gradients in the current color library, clibraries() to get a list of available color libraries

Seems i need to explicitly import every scheme before using? Strange though, it used to work before. Any help is much appreciated.

Hi!
Importing ColorSchemes seems to do the trick

using Plots, Random, ColorSchemes

It’s true that you can use colorschemes from ColorSchemes.jl without importing or using it - because I think it’s used and reexported by PlotUtils. So this works in a session that hasn’t imported or used ColorSchemes:

But this won’t give you access to other things from inside ColorSchemes.jl, such as the list of colorschemes, or the findcolorscheme() wildcard search function. For that, you would need to do a using or import…

I think that’s how it works… (Not sure really… :))

Still no cigar.

using Random, Plots, ColorSchemes
plot(randn(50, 5), palette = :vermeer)

ERROR: There is no gradient named vermeer . Use cgradients() to get a list of gradients in the current color library, clibraries() to get a list of available color libraries

Works for me. (Plots v1.10.5) (Although not the most realistic Vermeer I’ve seen.)

and as before you don’t need the using ... ColorSchemes for this to work, since PlotUtils does it for you. (Although you won’t be able to do collect(keys(colorschemes)) until you use or import it.)

It works now. Turns out installing JuliaDB broke Plots. I removed JuliaDB and it works again. Strange.

Thank you!

1 Like

Cool. It’s probably the same as https://github.com/JuliaData/JuliaDB.jl/issues/374, JuliaDB holding Plots back for some reason…

1 Like

Aha! Thanks for the reference Cormullion.

1 Like