Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dberardi99 wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromdberardi99:bugfix-for-issue-28268

Conversation

dberardi99
Copy link

PR summary

Added newreset property in theclear 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:

  • "Hard"clear (called withclear(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.)
  • "Soft"clear (called by default withclear() orcla()) is instead used to clear only data-like content, leaving the formatting unchanged

Closes#28268,closes#28846

PR checklist

Copy link

@github-actionsgithub-actionsbot left a 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 uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

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

@timhoffm
Copy link
Member

timhoffm commentedOct 14, 2024
edited
Loading

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

When'reset' is set toFalse, part of the formatting of the axis (labels and relative properties) is left unchanged.

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.

@jklymak
Copy link
Member

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.

@dberardi99
Copy link
Author

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)?
In this case this PR would close the only problems related to the labels position (that was my initial target here), leaving the other topics unsolved for now (e.g., resetting axis scale of child plot when clearing the parent one or not resetting tick label).

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 :)

@jklymak
Copy link
Member

@dberardi99 Thanks for taking a crack at this - your contribution is appreciated. Given how mature Matplotlib is, making changes to basic functionality likeax.clear is going to need a fair bit of thought and discussion.

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

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
Status: Needs decision
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[Bug]: Axes.cla() resets axis label position of twin axes [Bug]: y_label in wrong place after clearing for twinx axes
3 participants
@dberardi99@timhoffm@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp