Makie - how to set only lower or upper axis limit?

When plotting Makie automatically set axis limits. I would like to keep the automatically generated upper limit while setting the lower one to zero. How could I do that?

At first I wanted to get the current limits and reset them, but ax.limits give me (nothing, nothing).

I would have to add that scenario specifically, I guess I could go with ((nothing, lim), nothing) for setting the upper x limit, for example. What is the scenario in which you want to do this, so I understand it better. Are you adding plots but don’t want zero to shift? Also, ax.finallimits is what contains the actual current limits

I am plotting errors (always positive) for different methods. If the errors are all huge but one is like 1% smaller, having limits tight around the lines make it look like one method is much better than the other when really it is not. I want like the plot to start at 0 so that relative small difference or noise actually look small.

Using ax.finallimits I did the following

rect = ax.finallimits[]
topy = (rect.origin + rect.widths)[2]
ylims!(ax, -0.1*topy, topy)

which allows me to get what I want (okay I still need to move the legend)

It could be made nicer in the API but it works for me as it is :slight_smile:

1 Like

Sorry to revive an old topic. But was there a better way to do this added to the API in the end?

Similar to what you would do in pyplot, with set_ylim(bottom=0), to set the lower limit to 0 but letting the upper limit to be inferred from the data.

ylims!(low = 1) or xlims(high = 5) for example

https://docs.makie.org/stable/examples/blocks/axis/index.html#setting_half-automatic_limits

3 Likes