-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
[FR] Option to widen manual limits #3339
Comments
Wow what a coincidence, I came here to post about this exact issue and it's already the most recent one! I would put in a vote that widening would happen by default (i.e. not requiring |
I think this is reasonable. I'd appreciate if you are up to make a PR. PRs to improve the documentation are also welcome! |
Previously, the limits were not widened when passing a tuple or :round to lims (ignoring the widen argument). Fixes JuliaPlots#3339
Given that someone had intentionally implemented We can fall back on the |
Personally I would prefer always defaulting to
Technically this would also be a breaking change, but why would anyone pass |
I like that a lot |
Actually what I really would like is a new axis attribute lets say julia> plot(1:5) |> Plots.xlims # still widen by default
(0.88, 5.12)
julia> plot(1:5, xlimits_modifiers = :round) |> Plots.xlims # in this case same as `limits_modifiers = false/nothing/:none`
(1.0, 5.0)
julia> plot(1:5, xlimits_modifiers = (:widen, :round) |> Plots.xlims
(0.0, 6.0)
julia> plot(1:5, xlimits_modifiers = (:symmetric, :widen) |> Plots.xlims
(-5.12, 5.12) But I'm not sure we can do that non-breaking. |
Agreed. Something like that would be more consistent with Pots.jl style. However, this would be a substantially more involved change. Thus, I think it makes sense to merge my existing pull request, which implements @lllusion3418's :auto suggestion. |
Agreed. I'll put this in a seperate issue on the 2.0 milestone |
* Respect :widen when passing :lims Previously, the limits were not widened when passing a tuple or :round to lims (ignoring the widen argument). Fixes #3339 * Add default widen=:auto, which matches default before 43e9a34 * If widen is a Bool, it always determines whether widening occurs. * If widen is :auto (the defualt), widening occurs for appropriate seriestypes, unless lims were set manually * Update test/test_axes.jl Co-authored-by: Simon Christ <[email protected]> * fix docs for lims and widen interaction * Update .zenodo.json * Update test/test_axes.jl xlims != ylims Co-authored-by: Simon Christ <[email protected]> Co-authored-by: Simon Christ <[email protected]>
* Respect :widen when passing :lims Previously, the limits were not widened when passing a tuple or :round to lims (ignoring the widen argument). Fixes JuliaPlots#3339 * Add default widen=:auto, which matches default before 43e9a34 * If widen is a Bool, it always determines whether widening occurs. * If widen is :auto (the defualt), widening occurs for appropriate seriestypes, unless lims were set manually * Update test/test_axes.jl Co-authored-by: Simon Christ <[email protected]> * fix docs for lims and widen interaction * Update .zenodo.json * Update test/test_axes.jl xlims != ylims Co-authored-by: Simon Christ <[email protected]> Co-authored-by: Simon Christ <[email protected]>
Sorry if I missed a previous issue.
Plots.jl version: 1.10.6
In this case I tried using

ylims=(0,Inf)
to indicate that i want the y-axis to start at 0 (because here the area under the blue curve somewhat matters):This results in points at the maximum being cut off in the middle (and even the zero at the bottom isn't that pretty)! Because I couln't figure out another way except to calculate the maximum and use that times some factor (which I couldn't even do easily since they are a result of
scatterhist()
), I addedplot!([0],[0], markersize=0, primary=false)
to trick Plots.jl into thinking there was a point at y=0. This results in a somewhat nicer plot like this:I get that
lims
are supposed to specify exact limits but I would think that thewiden
parameter would accomplish exactly what I want. Instead it gets ignored when custom limits are passed since it defaults totrue
(whereas if you did want the current behaviour you would also have had the option to setwiden=false
). Since it's probably a bit late to change that, could there at least be an option likewiden = :force
? If that's an option, it seems simple enough that I could implement it.Another workaround I just found is using
ylims()
- adjusting that and passing it back in - but even that seems a bit complicated and hard to discover (is there a reason why there can't be some page just documenting all Plots.jl functions, or have I just somehow missed it? Examples are great but{x,y}lims()
and e.g.mp4()
don't seem to be mentioned anywhere).Easy way to reproduce (with any backend):
Edit: fwiw, this seems to work:
ylims!(Plots.widen(ylims()...))
(unless you're using an logarithmic scale)The text was updated successfully, but these errors were encountered: