Skip to content

Sync shared limits without callbacks#31905

Open
samiat4911 wants to merge 2 commits into
matplotlib:mainfrom
samiat4911:fix-shared-axis-limit-sync
Open

Sync shared limits without callbacks#31905
samiat4911 wants to merge 2 commits into
matplotlib:mainfrom
samiat4911:fix-shared-axis-limit-sync

Conversation

@samiat4911

Copy link
Copy Markdown

PR summary

Shared axes now remain synchronized when axis limits are changed with
emit=False.

Previously, Axis._set_lim() used emit to control both callback emission and
shared-axis limit propagation. As a result, calls such as:

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

updated only the first Axes. The shared Axes retained different limits while
using the same tick locator, which could produce incorrect tick positions.

This change separates shared-axis propagation from callback emission by adding
an internal propagation flag. The initiating call updates every shared Axes,
while propagated updates disable further propagation to prevent infinite
recursion. emit=False continues to suppress limit-change callbacks.

The existing shared-axis callback test now also verifies that:

  • x and y limits propagate to every Axes in a shared group when emit=False;
  • no callbacks are emitted by either the initiating or shared Axes.

This follows the design discussion in #26011.

Closes #26085

AI Disclosure

OpenAI Codex was used to implement the fix, add regression coverage, run available validation. The changes were reviewed and validated with local static checks and runtime smoke tests.

PR checklist

@samiat4911

Copy link
Copy Markdown
Author

hello @timhoffm would love you to take a look thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant