-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Labels
Milestone
Description
Bug summary
"x/ylim_changed" should be emitted whenever the limits of an axis is changed. However, when the limits are changed via as a consequence of ax.set_xticks, the signal is not emitted.
Code for reproduction
import matplotlib.pyplot as plt
def xlim_changed(ax):
print(f'xlim changed to: {ax.get_xlim()}')
fig, ax = plt.subplots()
ax.callbacks.connect("xlim_changed", xlim_changed)
ax.set_xlim(0.5, 1) # emits "xlim_changed" as expected
ax.set_xticks([0, 100]) # does not emit "xlim_changed"Actual outcome
xlim changed to: (np.float64(0.5), np.float64(1.0))
Expected outcome
xlim changed to: (np.float64(0.5), np.float64(1.0))
xlim changed to: (np.float64(0.0), np.float64(100.0))
Additional information
I became aware of this bug while working on #31214
for reference the plot produced by the above code looks like this:

Operating system
Ubuntu
Matplotlib Version
3.11.0.dev
Matplotlib Backend
No response
Python version
3.13
Jupyter version
No response
Installation
git checkout
Reactions are currently unavailable