When building up scatter or error bar plots of data, I frequently want to overlay a fitting function or other set of lines/bands. The latter need to extend for the full width/height of the Axes. If I'm using autoscaling, this doesn't happen because the scale adjusts to leave a margin around the new plots.
Currently, to avoid this, I need to do something like:
This means I am constrained in how I order my code—I have to have all my data contributing to autoscaling present before I add any fit lines. (This gets more complicated when I am working with multiple Axes with sharex or sharey.)
Example of what I might be looking for:
Example of what I currently get without the workaround above:
Proposed solution
Ideally, have a new keyword argument on plot and friends, something like use_in_autoscale: bool = True. When True, the object generated by plot contributes to the axis limit computations as currently; when False, then it is ignored in these computations.
Thanks @rcomer, I wasn't aware of axline—that plus axhspan do cover a decent amount of my needs, but not all of them, as sometimes I need to use fill_between with curves.
Activity
anntzer commented on Feb 17, 2025
See #15595 and linked issues.
edbennett commented on Feb 17, 2025
I searched for a while before raising but clearly used the wrong keywords, as I didn't turn up those. Thanks for pointing me at them!
rcomer commented on Feb 17, 2025
Specifically for straight lines, you can use axline.
edbennett commented on Feb 17, 2025
Thanks @rcomer, I wasn't aware of axline—that plus axhspan do cover a decent amount of my needs, but not all of them, as sometimes I need to use fill_between with curves.
jklymak commented on Feb 18, 2025
I dont' see any reason something like #15595 could not go through. It just needs someone interested in the capability to implement it.
timhoffm commented on Feb 18, 2025
The current architecture is somewhat messy, we probably need to clean that up first, but it should not be too hard #15595 (comment).