Get x and y limits of Makie plot

How to get axis limits?

scatter(50randn(5), 50randn(5))

julia> test = scatter(50randn(5), 50randn(5))

julia> propertynames(test)
(:figure, :axis, :plot)

julia> propertynames(test.axis)

# found axis limits eventually:

julia> test.axis.xaxis.attributes.limits.val
(-70.52889f0, 97.21371f0)
2 Likes

They are in ax.finallimits

julia> scatter(50randn(5), 50randn(5)).axis.finallimits[]
HyperRectangle{2, Float32}(Float32[0.0, 0.0], Float32[10.0, 10.0])

doesn’t look right

The first reset_limits! is called at display time as an optimization, you can call it yourself earlier

1 Like

Yeah that works.

julia> let p = scatter(50randn(5), 50randn(5))
           CairoMakie.reset_limits!(p.axis)
           p.axis.finallimits[]
       end
HyperRectangle{2, Float32}(Float32[-49.65375, -63.7986], Float32[45.149063, 95.1717])