Closed
Description
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
import datetime
import matplotlib.pyplot as plt
x = [datetime.date(year, 1, 1) for year in range(2020, 2024)]
y = range(4)
plt.plot(x, y)
plt.axhspan(1, 2)
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