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?
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
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.
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
@peterkovesi who developed GitHub - peterkovesi/PerceptualColourMaps.jl: Perceptually Uniform Colour Maps for Julia might have some thoughts as well.