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]: Changing limits by setting ticks does not emit "x/ylim_changed" #31247
"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
importmatplotlib.pyplotaspltdefxlim_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 expectedax.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:
@trygvrad Before updating the view interval, store the old axis limits.
After axis.set_view_interval(min(ticks), max(ticks)), compare the new limits with the old ones.
If they changed, trigger the xlim_changed callback so observers are notified.
Activity
Chirag3841 commentedon Mar 7, 2026
@trygvrad Before updating the view interval, store the old axis limits.
After axis.set_view_interval(min(ticks), max(ticks)), compare the new limits with the old ones.
If they changed, trigger the xlim_changed callback so observers are notified.
I would like to solve this issue same .