You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In matplotlib 3.9.0, when plotting dates on the X-axis, calling axhspan unexpectedly expands the X-axis range from 1970 to 2024. This behavior did not occur in version 3.8.4, where the X-axis correctly ranges from 2020 to 2024.
A bisect does indeed point to that commit; I'm a bit confused though as it seems like that change is supposed to try and avoid changing the datalimits, but maybe it's something to do with using date/units.
diff --git i/lib/matplotlib/axes/_axes.py w/lib/matplotlib/axes/_axes.py
index 9a2b367fb5..7efbd6562f 100644
--- i/lib/matplotlib/axes/_axes.py+++ w/lib/matplotlib/axes/_axes.py@@ -1028,7 +1028,7 @@ class Axes(_AxesBase):
# For Rectangles and non-separable transforms, add_patch can be buggy
# and update the x limits even though it shouldn't do so for an
# yaxis_transformed patch, so undo that update.
- ix = self.dataLim.intervalx+ ix = self.dataLim.intervalx.copy()
mx = self.dataLim.minposx
self.add_patch(p)
self.dataLim.intervalx = ix
(intervalx is an array and thus vulnerable to getting mutated in place). Note that axvspan already has the necessary copy() call, only axhspan was missing it.
Can you take over the patch?
Bug summary
In matplotlib 3.9.0, when plotting dates on the X-axis, calling axhspan unexpectedly expands the X-axis range from 1970 to 2024. This behavior did not occur in version 3.8.4, where the X-axis correctly ranges from 2020 to 2024.
Code for reproduction
Actual outcome
Expected outcome
Additional information
No response
Operating system
Fedora
Matplotlib Version
3.9.0
Matplotlib Backend
inline or Agg
Python version
3.12.3
Jupyter version
4.2.1
Installation
pip
The text was updated successfully, but these errors were encountered: