Current list of colorschemes in Plots.jl

Is there a command to find out all the currently defined colorschemes? The one below that used to work is not working anymore:

PlotUtils._gradients |> keys |> showall

Color gradients in Plots are arranged into color libraries. You don’t need to know or specify the color library to pick a color scheme, but they are useful for exploration. To get a list of all color libraries in Plots, use the clibraries function:

julia> clibraries()
5-element Array{Symbol,1}:

All but the :misc library are restricted to colorgradients that live up to the perceptual uniformity standards for scientific visualization (so you’ll have to look in the :misc library for a rainbow gradient). The Plots color library is loaded by default.
You can get a list of colorschemes in each gradient by calling e.g. cgradients(:colorcet). Or, you can use the showlibrary function to get a visual representation, e.g.



Each color library also defines a default gradient (:magma in the case of :Plots), a :sequential gradient, and a :diverging gradient (for color gradients that are brightest in the middle - in :Plots this is the :pu_or gradient).

You can change the active color library by clibrary(:colorbrewer). You can use any color gradient regardless of library by passing its name to the color attribute in Plots, but in case of namespace clashes (e.g. there are multiple :blues) it will default to the one in the current library.

I should add that you can reverse any color gradient by appending “_r”, e.g. :viridis_r.

I would strongly recommend exploring the :colorbrewer (from here), :colorcet (from e.g. here) and :cmocean (from here) libraries, they are very nice.


This is an awesome answer @mkborregaard! All I always wanted to know about colorschemes in Plots.jl, a big :+1:

Thanks for answering in detail, this will serve as documentation for future users.


This is indeed an excellent guide! Is there an equivalent for selecting discrete colors rather than gradients? In other words, if I do

ys = rand(10,5)

Colors are picked in order, it seems to maximize contrast. Is there a way to look at what the order is, or change it?

1 Like

The colors of different series is as default set with the distinguishable_colors function from Colors.jl, in order to maximize the contrast to the background. You can change it with the color_palette attribute, either passing a vector of colors to choose from, or the name of a gradient (it will select distinguishable colors from that gradient).

Alternatively you can set the look of all your plots with theme, e.g. to make the look of plots match your visual theme in juno:

p1=plot([cumsum(randn(100)) cumsum(randn(100))])
p2 = plot([sin, cos])


@mkborregaard, adding to the thread, how do you construct a color gradient with N specific colors? (e.g. [:red, :yellow, :blue])


You can’t at the moment. Color gradients in Plots are stretched/interpolated. A classified color map is on the todo:


@mkborregaard, I was asking for an interpolation method actually that given 3 colors let’s say, generates the color gradient. I just found the solution by digging into the source code:

using Plots

A = [i for i=1:100, j=1:100]

heatmap(A, c=ColorGradient([:red,:yellow,:blue]))



Ah, I misunderstood. The syntax is actually heatmap(A, c=cgrad([:red,:yellow,:blue])). The cgrad function also lets you associate each of the colors with a certain value, create uneven interpolations, specify that the color scale should be e.g. logged, and set an alpha value for the gradient. It’s all in the source code :slight_smile: You know, I think I should move some of this post to the Plots docs :slight_smile:


That would be great! Thanks for sharing the right way :slight_smile:


Is anything still missing from there in your view @yakir12?

IMO what you said earlier in this thread:

All but the :misc library are restricted to colorgradients that live up to the perceptual uniformity standards for scientific visualization

… is not clear in the docs, especially since the section on the Colorcet library is the only one that mentions perceptual uniformness (making it seem like none of the others have this property).

@mkborregaard, this is really great. Thank you very much. I especially think that the tutorial is useful. I was especially after the logarithmic color scale, a very cool option for heatmaps.

1 Like

Cool it’s useful - thank @SaschaMann who did the PR :slight_smile: The tutorial is really old and should perhaps be revisited :slight_smile: It’s an original by Tom Breloff.

@waldyrious yes that’s a good point :+1:

Very useful info in this thread!

I’ve always wondered about colors. Is it so that symbols for the CSS color names are supported, HTML Color Groups ? Seems like one can use symbols with the CSS color names in lowercase…, e.g.:

p1 = plot(x,y,lc=:red,label=L"\sin(x)\exp(-x/6)“);
p2 = plot(x,z,lc=:green,label=L”\cos(x)\exp(-x/8)“);
p3 = plot(x,u,lc=:cornflowerblue,label=L”\sinc(x)");

Some info I have had problems finding, related to layout… for more specialized layout, e.g:

plot(p1,p2,p3,p4, layout = @layout [a{0.4w} [b c;d]])

…is it so that “a”, “b”, “c”, “d” is some reference to p1, p2, p3, p4? (I assume so…), but I haven’t really found clear explanation of this.

A final couple of things I have wished for…

  • When doing parametric plots, e.g., with phase plots with time as parameter, it would be really useful to let the color of the curve change with the parameter. One can do this by splitting up the curve of N elements in N-1 straight lines, and assign a new color to each segment – e.g., using linspace between two RGB colors, but the resulting plotting is really slow.

  • I have tried to use 3D plot with contours. Doesn’t look nice if the min value of the surface is close to zero – this tends to hide the contours. It would be useful if one could specify at which “z” value the contours should appear. (This can relatively easily be done with Matplotlib/Pyplot).

plot(rand(10), line_z = 0.1:0.1:1)

contour(rand(10,10), levels = [0.2, 0.5])

Concerning layout, this tutorial may be helpful.

As a general rule though, this (a topic about colorschemes) is not the preferred place to ask usage questions about plots, either the gitter or the slack channels are probably better. Also, make sure to go through the documentation before asking and, once you figure out something that was not documented, please consider opening a PR to improve the documentation (which you can find here).


And yes, CSS color names are supported.

1 Like