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
{{ message }}
Repository navigation
[Bug]: Incorrect X-axis scaling with date values #28341
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?
Activity
timhoffm commentedon Jun 4, 2024
This is a regression in 3.9.
ksunden commentedon Jun 4, 2024
Most likely related to #26788
QuLogic commentedon Jun 4, 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.
cc @anntzer
anntzer commentedon Jun 5, 2024
Woops. The fix is easy:
(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?