-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
fetch rcParams for Figures in fig.clf(), issue #7434 #9622
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
Optionally fetch rcParams again in clf, issue matplotlib#7434
lib/matplotlib/figure.py
Outdated
self._suptitle = None | ||
self.stale = True | ||
|
||
def clear(self, keep_observers=False): | ||
def clear(self, keep_observers=False, disable_rc_fetch=True): |
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.
This needs to also pass the kwarg to clf
lib/matplotlib/figure.py
Outdated
@@ -1226,12 +1230,14 @@ def _break_share_link(ax, grouper): | |||
if last_ax is not None: | |||
_reset_loc_form(last_ax.xaxis) | |||
|
|||
def clf(self, keep_observers=False): | |||
def clf(self, keep_observers=False, disable_rc_fetch=True): |
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.
Despite my comments in #7434 , I think a non-inverted kwarg (ex reset_rcparams=False
) would be easier to understand.
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.
I agree. I'll change it.
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.
Thanks for working on this!
In addition to the two comments, this will need a test (so we don't break it in the future) and an entry in whats_new
(so people know it exists so they can use it).
If you are feeling ambitious can you also convert the docsctrings to numpydoc (https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt) format? |
lib/matplotlib/figure.py
Outdated
@@ -336,6 +336,7 @@ def __init__(self, | |||
raise ValueError('figure size must be finite not ' | |||
'{}'.format(figsize)) | |||
self.bbox_inches = Bbox.from_bounds(0, 0, *figsize) | |||
self.figsize = figsize |
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.
Why do we need these lines? How did these used to be handled?
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.
Because these parameters have to be accessed by clf, outside the scope of init. Before, they were only used within that scope.
fixed error: accidentally overwrote fig.tight_layout
I suggest that all these new attributes should be private (prefix with |
new figure properties set to private, and set the properties to their new values
I've made changes to make sure that the figure properties are actually changed to the fetched rcparams in clf, and the new attributes that were made to do this are now marked as private. |
The unit test, what's new entry, docstring et cetera are in there. |
I took a look at rebasing this and there have been enough changes to the @NNiehof I'm loath to close PRs, however I think given how far out of sync with the main branch this has gotten I am going to close it 😞 . I apologize that this get lost in review (which is on me), I hope we will hear from you again in the future. |
I guess we can say this has lost its relevance at this point 😄 |
PR Summary
Optionally consult rcParams again in clf, issue #7434
The parameters that
Figure
gets from rcParams on creation are optionally fetched again inclf
ifreset_rcparams
is set to True. By default, this is set to False and thus disabled.PR Checklist