Bug report
Consider you have a figure with multiple subplots sharing the X axis (fig.subplots(2, 2, sharex="all")). When using axhspan() in an Ax without data, the rest of Axes will change the X axis potentially leaving data outside the range.
Code for reproduction
import matplotlib.pyplot as plt
fig = plt.figure()
ax1, ax2 = fig.subplots(2, 1, sharex="all")
ax1.set_title("ax1")
ax2.set_title("ax2")
ax1.scatter([1, 2, 3, 4], [2, 3, 2, 3])
ax2.axhspan(-5, 5, alpha=0.2)
fig.show()
Actual outcome

Expected outcome
I expected both Axes to use a shared X axis in the range 1 to 4, because the data covers that interval

Matplotlib version
- Operating system: Debian 10
- Matplotlib version: 3.2.2
- Matplotlib backend (
print(matplotlib.get_backend())): nbAgg
- Python version: 3.7.3
- Jupyter version (if applicable): Happens outside of Jupyter as well
Installed via pip. Running inside a python3 -m venv
Thank you!
Bug report
Consider you have a figure with multiple subplots sharing the X axis (
fig.subplots(2, 2, sharex="all")). When usingaxhspan()in an Ax without data, the rest of Axes will change the X axis potentially leaving data outside the range.Code for reproduction
Actual outcome
Expected outcome
I expected both Axes to use a shared X axis in the range 1 to 4, because the data covers that interval
Matplotlib version
print(matplotlib.get_backend())): nbAggInstalled via pip. Running inside a
python3 -m venvThank you!