# New colorscheme for Plots.jl 2.0

**URL:** https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841
**Category:** Visualization
**Tags:** colors, poll, plots
**Created:** [August 5, 2024, 12:39pm UTC](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841 "2024-08-05T12:39:40Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)
#### Post date: [August 5, 2024, 12:39pm UTC](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841/1 "2024-08-05T12:39:40Z")

</div>

For the upcoming Plots.jl 2.0 we are thinking about changing the default colorschemes. We identified 3 potential candidates for a new color palette and 4 potential gradients. You can see the combinations in action in [this post on github](https://github.com/JuliaPlots/Plots.jl/issues/4966#issuecomment-2252918274).

Please cast your vote here:

_Poll ([view on site](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841/1))_

_Poll ([view on site](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841/1))_

_Poll ([view on site](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841/1))_

---

<div class="post-metadata">

### Author: ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)
#### Post date: [August 5, 2024, 2:55pm UTC](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841/2 "2024-08-05T14:55:24Z")

</div>

Graphics libraries like matplotlib, plotly, bokeh, altair, have as default gradient a perceptually uniform  
colorscheme, but not one defined according to a color model that has more than 40 years (Crameri’s scientific colormaps, Kovesi colormaps are defined using such a model).  
These libraries (matplotlib, plotly, bokeh, altair, etc) have as default sequential colorscheme one defined according to a colormodel, presented at the link that follows, i.e. the same colormodel used in the definition of viridis, plasma, inferno, magma, and cmocean colormaps). More details here [https://discourse.julialang.org/t/a-good-colorscheme-encodes-the-right-information-on-data-is-inferno-a-good-colorscheme/99962](https://discourse.julialang.org/t/a-good-colorscheme-encodes-the-right-information-on-data-is-inferno-a-good-colorscheme/99962).

Image illustrating that lajolla, devon, navia and lipari are not perceptually uniform:

 ![sci-colormaps](https://global.discourse-cdn.com/julialang/original/3X/d/d/dd8a2c9b828c8d3cc723c22ef019a395953cf4bd.jpeg)

A good choice could be one of the sequential colormaps from cmocean package:

 ![cmocean-colorschemes](https://global.discourse-cdn.com/julialang/original/3X/3/5/3519d46e319dca9918e12bef4c8461237ee742f5.jpeg)

---

<div class="post-metadata">

### Author: ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)
#### Post date: [August 5, 2024, 3:06pm UTC](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841/3 "2024-08-05T15:06:23Z")

</div>

Where can be found the definition of lipari and navia to check their lightness? A search in github repo, ColorSchemes.jl, doesn’t return a data file with these names?

---

<div class="post-metadata">

### Author: ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)
#### Post date: [August 5, 2024, 5:21pm UTC](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841/4 "2024-08-05T17:21:11Z")

</div>

> [@empet](#):
>
> A search in github repo, [ColorSchemes.jl](https://juliahub.com/ui/Packages/General/ColorSchemes), doesn’t return a data file with these names?

Github doesn’t search files larger than about 300KB. Because `ColorSchemes/data/scicolor.jl` is 827KB, it can’t be searched for in Github.

---

<div class="post-metadata">

### Author: ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)
#### Post date: [August 5, 2024, 5:37pm UTC](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841/5 "2024-08-05T17:37:20Z")

</div>

I’ve succeeded to get the files and inserted the plots of their lightness as can be seen above. Thanks!

---

<div class="post-metadata">

### Author: ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)
#### Post date: [August 5, 2024, 9:22pm UTC](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841/6 "2024-08-05T21:22:58Z")

</div>

Do I understand correctly that what we want is a colormap with low variation in the perceptual differences between adjacent colors? If `DE_2000` is a good metric of these differences then we can look at the standard deviation to find those with low variation?

```julia
using GLMakie, IterTools
firstarg(x, xs...) = x
let step = 1
    metric = DE_2000()
    syms = [:viridis, :inferno, :devon, :tokyo, :matter, :ice, :deep, :haline]
    fig = Figure()
    css = map(syms) do s
        getproperty(ColorSchemes, s).colors[begin:step:end]
    end
    dss = map(css) do cs
        IterTools.partition(cs, 2, 1) .|> splat((a,b) -> colordiff(a,b; metric))
    end
    order = sortperm(dss; by=std)
    syms = syms[order]
    css = css[order]
    dss = dss[order]
    Label(fig[1,1], "Perceptual differences\n$(typeof(metric))(colormap[$(step == 1 ? "" : step)n], colormap[$(step == 1 ? "" : step)(n+1)])"; fontsize=20, tellwidth=false)
    gl = GridLayout(fig[2,1], length(syms)+1, 4; font="Noto Sans")
    Label(gl[1,1], "colormap"; font="Noto Bold")
    Label(gl[1,2], "mean"; font="Noto Bold")
    Label(gl[1,3], "std"; font="Noto Bold")
    axes = map(enumerate(zip(syms, css, dss))) do (i, (sym, cs, ds))
        Label(gl[i+1,1], string(sym); tellheight=false, font="Noto Bold")
        Label(gl[i+1,2], string(round(mean(ds); digits=2)), tellheight=false)
        Label(gl[i+1,3], string(round(std(ds); digits=2)), tellheight=false)
        ylims = (0, 1.2step)
        ax = Axis(gl[i+1,4], limits=(nothing, ylims))
        heatmap!(ax, eachindex(cs), range(ylims[1], ylims[2]; length=10), firstarg; colormap=cs)
        lines!(ax, ds; color=:white)
        # lines don't support stroke (https://github.com/MakieOrg/Makie.jl/issues/1597), so hack it.
        lines!(ax, ds .- .02; color=:black, linewidth=.7)
        lines!(ax, ds .+ .02; color=:black, linewidth=.7)
        ax, std(ds)
    end
    save("/tmp/fig.png", fig; px_per_unit=2, size=(1200,800))
    fig
end

```

 ![fig](https://global.discourse-cdn.com/julialang/original/3X/6/0/60873d8e0433d1e55492872bc79462f26ac9ce63.png)

I think turbo is intended to make small differences visible, so I guess there’s an opportunity for comparing the std to the mean adjacent difference. As expected, turbo gives away some uniformity to get some more contrast.

```julia
let metric = DE_2000()
    syms = [:viridis, :inferno, :devon, :tokyo, :hawaii, :buda, :matter, :ice, :deep, :haline, :turbo]
    css = map(syms) do s
        getproperty(ColorSchemes, s).colors
    end
    dss = map(css) do cs
        IterTools.partition(cs, 2, 1) .|> splat((a,b) -> colordiff(a,b; metric))
    end
    fig = Figure()
    ax = Axis(fig[1,1]; title="$(typeof(metric)) adjacent differences", xlabel="mean", ylabel="std")
    text!(ax, sum.(dss)/256, std.(dss); text=string.(syms), align=(:center, :baseline))
    fig
end

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/3/3318e434cf7cdad4e6f3cf01250e62505630eba9.png)

@peterkovesi who developed [GitHub - peterkovesi/PerceptualColourMaps.jl: Perceptually Uniform Colour Maps for Julia](https://github.com/peterkovesi/PerceptualColourMaps.jl) might have some thoughts as well.

---

<div class="post-metadata">

### Author: ![halleysfifthinc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/halleysfifthinc/32/206280_2.png) [@halleysfifthinc](https://discourse.julialang.org/u/halleysfifthinc)
#### Post date: [August 5, 2024, 9:37pm UTC](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841/7 "2024-08-05T21:37:14Z")

</div>

I strongly second that the default gradient should be perceptually uniform.

---

<div class="post-metadata">

### Author: ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)
#### Post date: [August 5, 2024, 10:32pm UTC](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841/8 "2024-08-05T22:32:48Z")

</div>

I recall that a colorscheme is perceptually uniform if transforming each RGB color in its definition to a color in the space CAM02-UCS, of coords (lightness, chroma, hue), the lightness is linear. This means that the graph of the function that associates to each normalized value x\in [0,1] the lightness if its corresponding color in the colorscheme is a line. In the plots posted above the graph of lightness of the lajolla, devon, navia and lipari are not straight lines.

---

<div class="post-metadata">

### Author: ![ElOceanografo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eloceanografo/32/624_2.png) [@ElOceanografo](https://discourse.julialang.org/u/ElOceanografo)
#### Post date: [August 6, 2024, 1:54am UTC](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841/9 "2024-08-06T01:54:01Z")

</div>

+1 for perceptual uniformity. I like the magma colormap a lot, and the similar Cmocean matter. Viridis and haline are good too.

---

<div class="post-metadata">

### Author: ![Crameri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/crameri/32/211993_2.png) [@Crameri](https://discourse.julialang.org/u/Crameri)
#### Post date: [September 16, 2024, 7:08pm UTC](https://discourse.julialang.org/t/new-colorscheme-for-plots-jl-2-0/117841/10 "2024-09-16T19:08:00Z")

</div>

Nice effort! – Thanks.
