-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: fill_between{x} does not respect Axes transform #25682
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
Comments
matplotlib/lib/matplotlib/axes/_axes.py Line 5413 in b86ebba
So the fundamental thing here is that But it does call I think when you are doing things in the (default) data axes, you do want to expand the lims. One way to do that would be to manipulate the Alternatively it could be treated like matplotlib/lib/matplotlib/axes/_axes.py Lines 910 to 913 in b86ebba
|
That is probably the better option. |
Hey, I'm looking to be a new contributor to the project. Like @ksunden suggested, it seems like amending
to
in I'm going to open a pull request - does this seem like a reasonable solution? |
Bug summary
Using an axes transform with
fill_between
andfill_betweenx
incorrectly sets the axes limits if the Axes coordinates are larger than the data coordinates.Code for reproduction
Actual outcome
Note that code is slightly modified from the example in the documentation, but with the y-data values and threshold reduced by a factor of 10. What you get a plot where the y-limits have been expanded as if I've plotted y-data spanning between (0,1), but get a fill that covers the entire axis space.
Expected outcome
Should look like the example in the documentation, but with y axis labels reduced by a factor of 10.
Additional information
My guess is that the y-axis limits are being set by the
y1
/y2
values in data coordinates before the transform is applied to actually fill the regions. You will get the expected result as long as the provided Axes coordinate values are less than the extreme values of the y-data itself.For example

ax.fill_between(x, 0, 0.1, ...)
gives a correct result.But this issue means that you can't span the axes using this technique if your plotted data does not already span y=(0,1).
Operating system
Windows 10
Matplotlib Version
3.7.1
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
3.8.16
Jupyter version
3.5.3
Installation
conda
The text was updated successfully, but these errors were encountered: