Sometimes when I use log10
as the axis scale and IntervalsBetween(9)
as the minorticks, if the data range is not large enough such that less than two majorticks are displayed, all the minorticks are missing. For example, with the following codes:
using CairoMakie
set_theme!()
set_theme!(
Axis = (
yscale = log10, yticks=[1, 10],
yminorticksvisible=true, yminorticks=IntervalsBetween(9),
)
)
fig = Figure()
ax1 = Axis(fig[1,1])
scatter!(ax1, 0.5:0.5:12)
ax2 = Axis(fig[1,2])
scatter!(ax2, 1.5:0.5:12)
display(fig)
I get this plot:
Assume I don’t know the actual data range beforehand (since I’m making a large number of similar plots and it’s inconvenient to manually set yminorticks
for each plot), is there a way to force the minorticks for the right plot to appear without having at least two majorticks?
One way I can think of is to first retrieve the actual axis limit, and once I know the lower and upper bound of the axis limit, I can then set yminorticks
automatically based on the bounds, but ax.limits
gives me Observable{Any}((nothing, nothing))
which is not useful.
I can also set something like ax.yminorticks = 10 .^ (-1:0.1:2)
since I do know roughly the order of magnitude of the actual data, but then minorticks appear outside of the axis if the values of the minorticks are outside the axis bound so this is method is also not great.