-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Make Figure.frameon a thin wrapper for the patch visibility. #11691
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
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.
Please hold for 3.1
Anyone can dismiss this after 3.0 is branched.
The following API elements are deprecated: | ||
|
||
- ``Figure.frameon``, ``Figure.get_frameon``, ``Figure.set_frameon`` (directly | ||
manipulate the visibility of ``Figure.rect`` instead), |
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.
Do you mean Figure.patch
here?
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.
yes, fixed
Does this solve #10939? |
No, for that you want to look at #11692. |
Are the changes to Technically this simplifies things. |
dca5207
to
4ed83c1
Compare
Got rid of the (bookkeeping) change to whatsnew. |
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.
Not sure about having users drill down to the patch
property. Will most people know about this property of the figure? Right now we have, for instance get_facecolor/set_facecolor (and edgecolor, but not linewidth :eyeroll:) . Are you proposing to do away with those at some point in favour of the patch
methods? If not, I'd suggest we still need something equivalent at the figure
level: set_frameon/get_frameon.
I'm somewhat -0.5 on making the API less discoverable unless there is a good reason for the user to know the underlying structure of how an object is made. Is there a reason for the user to know that a Figure
has a patch to handle its style? If we are going to do this, at the very least the docstring for Figure
would need to be expanded to explain that the patch
is the object for manipulating the relevant properties.
That's essentially the problem: we have a top layer (Figure) partially duplicating a bottom layer (Figure.patch), but not completely and some things under different names (set_visible -> set_frameon, although naming it set_visible wouldn't work either as that'd imply not drawing the child artists either). I actually think pointing the user to do everything on the .patch would make the API simpler for the end user, not less. |
We should decide if that is the way to go, and do it all then and thoroughly update the docs. I guess Personally I'm 50/50 on going this way, versus just adding |
I'm -0.5 on adding additional figure methods to control the patch. It wouldn't end with Once this is done, there is no need for I'm not sure about the name
or
or
Another aspect is the |
We already have
|
I don't think it makes sense to deprecate existing/widespread API (
is a perfectly valid API. Anything that requires the user to think more about this, cannot be seen as improvement. Having two or more layers in the code can be problematic, but it isn't in this case, when Hence: |
Would you consider that by the same argument #10088 was going in the wrong direction? In my opinion, the problem of such additional layers is that they both make it harder to write correct code (the actual visibility state is |
I'm totally in favour of making The same could have been done in #10088. There is no benefit of not having this kind of thin-wrapping properties, other than less code lines. But removing them might break people's code. Because they were not implemented as properties, code breaks in an intransparent way now. There is no indication that |
Again, I disagree, although even more strongly for #10088, where the names (label1On, etc.) clearly point to the corresponding attributes (label1, etc.): I want to encourage users to use generic utilities (set_visible()) rather than specific ones (label1On), as that knowledge is more widely applicable. The new implementation of SkewT, for example, demonstrates a general, reusable method of manipulating sub-artist visibility in draw(), rather than being completely specific to SkewT.
Actually I implemented them as properties for the deprecation period, so that a deprecation warning does get emitted... |
See also discussion surrounding https://github.com/matplotlib/matplotlib/pull/12241/files#r223905198 for code that would become simpler if visibility just meant, well, {get,set}_visible(), instead of having to check on other attributes. |
You'd be totally free to use |
I undeprecated frameon to move this PR forward (it is now just an alias for the visibility state of the underlying patch). |
Directly manipulating the visibility of Figure.patch is just as good.
79a11a2
to
5b2cfd9
Compare
👍 Do you want to update any docstrings? Something like "This is a convenience wrapper for |
Please push the changes as desired. |
@ImportanceOfBeingErnest Note, by the way, that having #10088 would have avoided the issue around #10981, namely that we were using one way, internally, to control visibility, whereas the user may be using another knob (although I guess this doesn't argue against having two synonyms for the same setting, but heh). |
I consider this a major difference. Just leveling up some properties is totally different from having two (or more) separate code paths. I will look at the documentation for this latest on Saturday. If someone wants to merge in between, I can also open a new PR. |
Ok, so how do I push to this PR? Is this the right strategy? It seems that I would need to clone your complete fork to a local folder, which seems a bit strange/overkill. |
You don't need a new clone; just some remotes pointing to the fork, or use the fork's URL directly. To pull a PR's contents (if
You could also pull directly from someone's fork:
(or use the To push to @anntzer's fork:
(or use the |
Technically I guess so, although I'd like to suggest a change of policy wrt these "collaborative" PRs (namely that we can just have separate approval by enough devs for each part of the PR). |
Not sure if this has enough reviewers overall. If @anntzer and @ImportanceOfBeingErnest each approve their collaborative code, that would be 1 plus 1 by me. IMO, @anntzer if you approve the changes of @ImportanceOfBeingErnest you can self-merge. |
I approve @ImportanceOfBeingErnest's patch. |
Directly manipulating the visibility of Figure.patch is just as good.
Similar in spirit to #10088, but hopefully less controversial.
PR Summary
PR Checklist