Skip to content

FIX: prevent log-scale warning in _AxesBase._clear for log scales#31403

Open
marcchahwan wants to merge 1 commit intomatplotlib:mainfrom
marcchahwan:main
Open

FIX: prevent log-scale warning in _AxesBase._clear for log scales#31403
marcchahwan wants to merge 1 commit intomatplotlib:mainfrom
marcchahwan:main

Conversation

@marcchahwan
Copy link

PR summary

import matplotlib.pyplot as plt

Setup a figure with a logarithmic scale

fig, ax = plt.subplots()
ax.set_xscale('log')

In current main, calling clear() (or cla()/clf()) triggers:

UserWarning: Attempted to set non-positive xlimits on stderr.

With this PR, the warning is eliminated as limits are set to (nonpos, 1).

ax.clear()

plt.show()

AI Disclosure

I utilized Gemini to assist in the verification and testing phase of this PR. It also assisted in the design of a minimal reproduction script to verify that the Userwarning was successfully eliminated and ensured the implementation adhered to Matplotlib’s internal standards for handling non-linear scales.

PR checklist

@github-actions
Copy link

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 gitter 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.

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

1 participant