Hi, using Plots.jl
and GR
backend, how to set custom (text) colorbar tick-labels for each of the 5 color “bins” from this MWE
using Plots.jl
heatmap(rand(5,5), color=palette(:inferno, 5))
Thanks !
Hi, using Plots.jl
and GR
backend, how to set custom (text) colorbar tick-labels for each of the 5 color “bins” from this MWE
using Plots.jl
heatmap(rand(5,5), color=palette(:inferno, 5))
Thanks !
It doesn’t seem that this is currently possible with the Plots.jl gr() backend.
It might be feasible with the pyplot backend - linking related thread.
Thanks for the related links! Will check out the potential of the pyplot
backend for that purpose. Could be a nice to have at some point.
Any update on whether this is possible with gr() yet?
Everything is possible, with some imagination:
using Measures, Plots; gr()
n = 5
z = rand(10,10)
clrticks = ["C$i" for i in 1:n]
yt = range(0,1,n+1)[1:n] .+ 0.5/n
l = @layout [ a{0.80w} [b{0.1h}; c] ]
colors = cgrad(:inferno, n, categorical=true)
p1 = heatmap(z, color=colors, cbar=false);
p2 = plot([NaN], lims=(0,1), framestyle=:none, legend=false);
annotate!(0.5, -0.1, text("Colors", 10, "Computer Modern"))
xx = range(0,1,100)
zz = zero(xx)' .+ xx
p3 = heatmap(xx, xx, zz, ticks=false, ratio=10, legend=false, fc=colors, lims=(0,1),
framestyle=:box, right_margin=20mm);
[annotate!(1.5, yi, text(ti, 7, "Computer Modern")) for (yi,ti) in zip(yt,clrticks)]
plot(p1, p2, p3, layout=l, margins=0mm)
Is this still not supported? It seems the GitHub issue has been in the same state for a while.
Hope the feature can be added soon.