Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make autolimits! default to current_axis() #3469

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/makielayout/blocks/axis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -897,14 +897,17 @@ function update_linked_limits!(block_limit_linking, xaxislinks, yaxislinks, tlim
end

"""
autolimits!()
autolimits!(la::Axis)

Reset manually specified limits of `la` to an automatically determined rectangle, that depends on the data limits of all plot objects in the axis, as well as the autolimit margins for x and y axis.
The argument `la` defaults to `current_axis()`.
"""
function autolimits!(ax::Axis)
ax.limits[] = (nothing, nothing)
return
end
autolimits!() = autolimits!(current_axis())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should check for current_axis returning nothing!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a very good idea. I implemented this check. Below is a demo:

julia> using GLMakie

julia> Makie.autolimits!
autolimits! (generic function with 4 methods)

julia> function autolimits!()
           curr_ax = current_axis()
           isnothing(curr_ax)  &&  throw(ArgumentError("Attempted to call `autolimits!` on `current_axis()`, but `current_axis()` returned nothing."))
           autolimits!()
       end
autolimits! (generic function with 1 method)

julia> autolimits!()
ERROR: ArgumentError: Attempted to call `autolimits!` on `current_axis()`, but `current_axis()` returned nothing.
Stacktrace:
 [1] autolimits!()
   @ Main ./REPL[5]:3
 [2] top-level scope
   @ REPL[6]:1


function autolimits(ax::Axis, dim::Integer)
# try getting x limits for the axis and then union them with linked axes
Expand Down
Loading