-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add new "reset" property to clear (cla) method #28974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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
We strive to be a welcoming and open project. Please follow our Code of Conduct.
I'm a bit skeptical that adding reset kwarg may be too ad-hoc and won't carry us through all clear-related issues ( #28851). While it may be a route to make clear() behavior configurable, are we sure there are only to variants, so that a bool parameter is sufficient? You write
That's too imprecise. We need to be very clear what is changed and what not. The naming "reset" is quite generic. Have you thoroughly reflected whether this is the best name? Is there a reason to use **kwargs? If possible, explict parameters with a default should be preferred. |
Agree with @timhoffm that this is not the correct approach here. Multiple meanings of "clear" are just going to get confusing and there will always be the question of where to draw the line of what gets cleared and what does not. |
Thanks for your feedback @timhoffm and @jklymak You're right that this is not the solution for all the problems cited in #28851 as well as that in this case an explicit parameter with a default value would be preferred being the "reset" parameter always used in the function. Then how do we want to treat this PR? Do we want to proceed as suggested by @jklymak and as said here #28268 (comment)? IMHO it is a good idea to proceed with @jklymak solution since it won't create too much confusion, but it would also be a good enhancement to make clear() behaviour more customizable (not using just a bool parameter like my "reset" but something more explanatory that could accept multiple values as you said) That's my first PR so pardon me if it is not perfect :) |
@dberardi99 Thanks for taking a crack at this - your contribution is appreciated. Given how mature Matplotlib is, making changes to basic functionality like |
PR summary
Added new reset property in the clear method to avoid unexpected results while working with twin axes etc.
The concept of this modification is to introduce a sort of "hard" and "soft" clear to give the user an increased control over this functionality:
clear(reset=True)
orcla(reset=True)
) is intended to clear data-like content as well as to clear the formatting (thus axes labels, colors, position, etc.)clear()
orcla()
) is instead used to clear only data-like content, leaving the formatting unchangedCloses #28268, closes #28846
PR checklist