-
-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Heatmap with log scale colorbar (cscale) ? #1405
Comments
Following https://discourse.julialang.org/t/heatmap-with-log-scale-colorbar-cscale/63018/2, let
x = 10.0.^(1:0.1:4)
y = 1.0:0.1:5.0
data = x .* ones(Float64, 1, length(y))
fig = Figure()
cmap = cgrad(:viridis, scale=:log10)
ax, hm = heatmap(fig[1, 1], x, y, data; colormap=cmap,
axis=(;xscale=log10,
xminorticksvisible=true,
xminorticks=IntervalsBetween(9))
)
cb = Colorbar(fig[1, 2], hm;
minorticksvisible=true,
minorticks=IntervalsBetween(9),
scale=log10
)
fig
end The issue is that the colormap is not the regular one. |
Any progress here? |
You're applying the scale twice AFAICT. Creatimg the colorbar without scale should lead to the "correct" colormap showing up. |
@asinghvi17 creating the colorbar without scale yields a colorbar without "log scale" ticks, codelet
x = 10.0.^(1:0.1:4)
y = 1.0:0.1:5.0
data = x .* ones(Float64, 1, length(y))
fig = Figure()
cmap = cgrad(:viridis, scale=:log10)
ax, hm = heatmap(fig[1, 1], x, y, data; colormap=cmap,
axis=(;xscale=log10,
xminorticksvisible=true,
xminorticks=IntervalsBetween(9))
)
cb = Colorbar(fig[1, 2], hm;
minorticksvisible=true,
minorticks=IntervalsBetween(9),
#scale=log10 # without this, the colorbar ticks are not log spaced
)
fig
end |
Oops, I guess I misinterpreted where the bug was. Which Makie versions are you on? There was a bug which was fixed recently (Makie 0.17.4 afaik)... |
The latest: |
A workaround is to modify the scale and limits of the colorbar axis after creating it. This seems to re-label the axis as desired without also transforming the actual color bar. x = 10.0.^(1:0.1:4)
y = 1.0:0.1:5.0
data = x .* ones(Float64, 1, length(y))
fig = Figure()
ax, hm = heatmap(fig[1, 1], x, y, log10.(data))
ax.xscale = log10
cb = Colorbar(fig[1, 2], hm)
cb.axis.attributes[:scale][] = log10
cb.axis.attributes[:limits][] = exp10.(cb.axis.attributes[:limits][]) |
Unfortunately the workaround doesn't work when values start below 10:
reports error:
|
I encountered the same issue. Is there a fix? |
#2493 would fix this. |
Great, I"ll wait then until merged. |
Can be closed (fixed by #2900). |
Reposted from discourse,
with updated CairoMakie, figures and link to documentation.
Makie is awesome, looks like everything is doable 🙂,
for instance, this heatmap with log scale color axis (exactly what I wanted):
Code for the above figure
But it was a bit involved for a newcomer. Here is how I would have expected it to work:
Currently (

CairoMakie v0.6.2
) thecscale
argument is just ignored:also tried
zscale
and read the documentation of course, in particularhttps://makie.juliaplots.org/stable/examples/layoutables/axis/index.html#log_scales_and_other_axis_scales
Would it make sense to add this
cscale
argument, for symetry withxscale
oryscale
?It has exactly the same meaning:
actually plot
log10(axis value)
on an underlying linear axis,and tweak ticks, minorticks and tick labels.
The text was updated successfully, but these errors were encountered: