Makie: adding more ticks to log axis

Hello everyone,

In Makie, what would be the simplest way to add more ticks to the following axis:

image

Using xticks = collect(logrange(1e-5, 1e1, 7)) puts the ticks where I want them to be, but they’re displayed with decimals (0.001) instead of using the notation above (10^-3).

Looking at the documentation for xticks, it’s not immediately obvious how “LogTicks” work. Am I missing something perhaps?

Surely the xticks = (numbers, labels) method would do the job, but I imagine there must be a more suitable method.

EDIT: I misread your problem! My reply does not answer your question.

Set xticks as you need and set the xscale argument of the Axis to xscale=log10:

using CairoMakie
fig = Figure()
ax = Axis(fig[1, 1], xticks=[1, 5, 10, 50, 100], xscale=log10)
scatter!(ax, rand(1:100, 1000), rand(1000))

Here is a MRE for my case (sorry for not including in original post):

xvalues = collect(logrange(1e-5, 1e1, 7))

f = Figure()
ax = Axis(f[1, 1], xscale = log10, 
          xticks = xvalues
          )

lines!(ax, xvalues, xvalues)

I would like the ticks to be in powers of 10 instead of decimal numbers.

How about this:

f = Figure()
ax = Axis(f[1, 1], xticks=LogTicks(WilkinsonTicks(6, k_min=5)), xscale=log10)
scatter!(ax, rand(1:(10^7), 100000) ./ (10^6), rand(100000))

2 Likes

If you are already ok with the default tick labeling and you just want more ticks (without labels), you could try setting the xminorticks interval like this:

ax.xminorticks = IntervalsBetween(5)
1 Like

That seems okay, thanks!

I’d like them labeled in this case, but thanks for the input.

You can do xticks = LogTicks(0:3) to get 10^0 to 10^3

2 Likes

Thanks jules, that’s what I was looking for!

Might be a good idea to add such an example in the documentation?
The current one reads:

  • LogTicks, a wrapper that applies any other wrapped tick finder on log-transformed values

, and that doesn’t explain much I’m afraid.

Agreed, can you open an issue so we can keep track?

2 Likes

Done :slight_smile:
“Bug” label was added automatically from github, not sure how to edit it.