◐ Shell
clean mode source ↗

[Bug]: Should Axes.set_xlim(..., emit=False) really not sync shared axes?

Bug summary

Currently, calling ax.set_xlim(..., emit=False) explicitly does not sync the xlims to other axes that are sharex with ax (i.e. the other axes keep their previous limits). This isn't really an accident of implementation, but is rather explicitly implemented at the bottom of Axis._set_lim.

However, this leads to buggy behavior, e.g. tick locators, which are shared between sharex axes, mis-handled being simultaneously assigned to two axes with different limits.

Code for reproduction

fig, axs = subplots(1, 2, sharex=True); axs[0].set_xlim((0, .1), emit=False)

Actual outcome

test
Note the nonsensical ticks on the second axis, which still have limits of (0, 1) but uses a tick locator which thinks the limits are (0, 0.1).

Expected outcome

Probably syncing with sharex axes should always be done, even when emit=False.

Additional information

No response

Operating system

No response

Matplotlib Version

3.8.0.dev1236+gfc350ea534

Matplotlib Backend

any

Python version

3.11

Jupyter version

No response

Installation

git checkout