Hello,
I cannot figure out how to properly set a log10 axis scale for heatmaps. I get an error of invalid x-limits even if I set positive axis limits. I know log10 is not defined for negative values (when I dont want a complex number). As a workaround I can manually specify the ticklabels, but this is quite some work. The same code works for a scatterplot. Many thanks for your help!
using GLMakie
## Heatmap with log10 scales axes does not work
## even when I set axis limits
let
xs = [ 10^2, 10^2, 10^3, 10^3]
ys = [10^-3, 10^-2, 10^-3, 10^-2]
zs = [1, 2, 3, 4]
fig = Figure()
ax1 = Axis(fig[1,1]; yscale=log10, xscale=log10)
limits!(ax1, 10^1, 10^3, 10^-3, 10^-1)
heatmap!(ax1, xs, ys, zs)
fig
end
# LoadError: Found invalid x-limits (-350.0f0, 1450.0f0) for scale log10 which is defined on the interval 0.0..Inf (open)
## it works for a scatterplot
let
xs = [ 10^2, 10^2, 10^3, 10^3]
ys = [10^-3, 10^-2, 10^-3, 10^-2]
zs = [1, 2, 3, 4]
fig = Figure()
ax1 = Axis(fig[1,1]; yscale=log10, xscale=log10)
scatter!(xs, ys; color=zs, markersize=50)
fig
end
## workaround: set manual ticklabels
let
xs = [1, 1, 2, 2]
ys = [1, 2, 1, 2]
zs = [1, 2, 3, 4]
fig = Figure()
ax1 = Axis(fig[1,1];
xticks=(1:2, ["10²", "10³"]),
yticks=(1:2, ["10⁻³", "10⁻²"]))
heatmap!(xs, ys, zs)
fig
end