Skip to content

fetch rcParams for Figures in fig.clf(), issue #7434 - #9622

Closed
NNiehof wants to merge 7 commits into
matplotlib:mainfrom
NNiehof:rcparams_fetch
Closed

NNiehof wants to merge 7 commits into
matplotlib:mainfrom
NNiehof:rcparams_fetch

Conversation

@NNiehof

@NNiehof NNiehof commented Oct 29, 2017 •

Copy link
Copy Markdown

PR Summary

Optionally consult rcParams again in clf, issue #7434
The parameters that Figure gets from rcParams on creation are optionally fetched again in clf if reset_rcparams is set to True. By default, this is set to False and thus disabled.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Optionally fetch rcParams again in clf, issue matplotlib#7434
@tacaswell tacaswell added this to the v2.2 milestone Oct 29, 2017
Comment thread lib/matplotlib/figure.py Outdated
self.stale = True

def clear(self, keep_observers=False):
def clear(self, keep_observers=False, disable_rc_fetch=True):

Copy link
Copy Markdown
Member

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

Comment thread lib/matplotlib/figure.py Outdated
_reset_loc_form(last_ax.xaxis)

def clf(self, keep_observers=False):
def clf(self, keep_observers=False, disable_rc_fetch=True):

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Author

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.

@tacaswell tacaswell left a comment

Copy link
Copy Markdown
Member

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

@tacaswell

Copy link
Copy Markdown
Member

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?

Comment thread lib/matplotlib/figure.py Outdated
raise ValueError('figure size must be finite not '
'{}'.format(figsize))
self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
self.figsize = figsize

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Author

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
@QuLogic

QuLogic commented Nov 13, 2017

Copy link
Copy Markdown
Member

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
@NNiehof

NNiehof commented Nov 20, 2017

Copy link
Copy Markdown
Author

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.

@NNiehof

NNiehof commented Dec 10, 2017

Copy link
Copy Markdown
Author

The unit test, what's new entry, docstring et cetera are in there.

@jklymak
jklymak marked this pull request as draft September 12, 2020 20:40
@jklymak
jklymak requested review from tacaswell and removed request for tacaswell September 12, 2020 20:40
@tacaswell

Copy link
Copy Markdown
Member

I took a look at rebasing this and there have been enough changes to the figure.py that it is probably easier to re-implement this than to actually do the rebase.

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

@tacaswell tacaswell closed this Dec 4, 2022
@NNiehof

NNiehof commented Dec 4, 2022

Copy link
Copy Markdown
Author

I guess we can say this has lost its relevance at this point 😄

@tacaswell tacaswell removed this from the future releases milestone Dec 5, 2022
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.

4 participants