Skip to content

FIX: remove warning when clearing axes with shared axis - #32069

Merged
QuLogic merged 6 commits into
matplotlib:mainfrom
dkludwig:bugfix/9970-shared-axis-clear
Jul 22, 2026
Merged

FIX: remove warning when clearing axes with shared axis#32069
QuLogic merged 6 commits into
matplotlib:mainfrom
dkludwig:bugfix/9970-shared-axis-clear

Conversation

@dkludwig

@dkludwig dkludwig commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

PR summary

fig, (ax1, ax2) = plt.subplots(1, 2, sharex=True)
x = range(1, 10)
ax1.semilogx(x, x)
ax2.semilogx(x, x)
fig.clf()

Would result in the following warning:

/Users/ben2/a/scratch.py:8: UserWarning: Attempt to set non-positive xlim on a log-scaled axis will be ignored.
  fig.clf()

AI Disclosure

No AI was used

PR checklist

@github-actions

Copy link
Copy Markdown

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process.

You can also join us on discourse chat for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@tacaswell

Copy link
Copy Markdown
Member

Can you please also add a test?

@dkludwig
dkludwig force-pushed the bugfix/9970-shared-axis-clear branch from 34fbae0 to 0370a17 Compare July 19, 2026 12:52
@dkludwig

Copy link
Copy Markdown
Contributor Author

Sure, should be good now

Comment thread lib/matplotlib/axes/_base.py Outdated
@dkludwig
dkludwig force-pushed the bugfix/9970-shared-axis-clear branch from 43c6088 to 7be82a4 Compare July 22, 2026 00:23
@QuLogic QuLogic added this to the v3.11.2 milestone Jul 22, 2026
@QuLogic
QuLogic merged commit 102a1d2 into matplotlib:main Jul 22, 2026
41 checks passed
timhoffm added a commit that referenced this pull request Jul 22, 2026
…069-on-v3.11.x

Backport PR #32069 on branch v3.11.x (FIX: remove warning when clearing axes with shared axis)
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.

clearing axes with shared axis with non-linear scales should not warn

4 participants