How to log10 scale on bar plot y axis with Makie

I am trying to display a bar plot with a log10 scale in the y axis, but I get the error Found invalid x-limits (0.0f0, 125.0f0) for scale log10 which is defined on the interval 0.0..Inf (open) despite my data not containing any zeros.

Here is the code that produces the error:

f = Figure()
xs = [1,2,3,4]
ys = [2,5,3,100]
ax = Axis(f[1,1],
    yscale = log10)
barplot!(ax,xs,ys)
display(f)

This works fine without the yscale :

f = Figure()
xs = [1,2,3,4]
ys = [2,5,3,100]
ax = Axis(f[1,1],)
   # yscale = log10)
barplot!(ax,xs,ys)
display(f)

Please help!

1 Like

Your data doesn’t contain zero, but by default a barplot is drawn from offset = 0 to your values, so that’s where the 0 comes from. It’s tricky because the projection part of the rendering system doesn’t care how you think barplots should behave on a high level, it just sees the coordinates of the polygon vertices. But as your plot can’t start at 0 with log axis, you have to decide what should happen. Either you let the barplot start at some value > 0 or you pick a different axis scale. This exact issue with barplots is also mentioned in the docs here Axis

Hi Jules, thank you that docs link has sorted it!