Skip to content

consult rcParams for Figures on fig.clf #7434

Closed as not planned
Closed as not planned

Description

@kaufman

version: 2.0.0b1+1773.g3590ce2
installed from src, OSX, gtk backend

if I have in rcParams:
figure.subplot.top=0.9

and I do:

figure()
clf()
plot([],[])
draw()
show()

then, the top margin is respected, but if I already have a window with figure already open and I do

style.use('x') # where x.mplstyle has figure.subplot: 0.5
clf()
plot([],[])
draw()

then then top margin is not altered from 0.9 (like I might expect when changing the style).
I have to close the window and create a new one for this style change to have an effect. This is not expected behavior.

Activity

  1. tacaswell commented on Nov 9, 2016

    @tacaswell
    Member

    Yes, the rcparams are locked in when the objects are created, thus changing the rcparams / style only affects newly created objects.

    This is a feature so that style context managers work.

  2. kaufman commented on Nov 9, 2016

    @kaufman
    ContributorAuthor

    Then it seems that clf() is not performing quite as much work as I thought. Would it be possible to modify subplots_adjust() to take no arguments and simply update to the current set of rcParams? That way, changing the margins inside a context manager would work as long as you add the subplots_adjust() function call (and if the rcParams margins are the same as the figure margins it would act as a noop).

  3. added this to the milestone on Nov 9, 2016
  4. tacaswell commented on Nov 9, 2016

    @tacaswell
    Member

    So the current behavior of subplots_adjust (which it gets from the update method of SubplotParams is to update only the values that are being changed by the call, and fall back to the rc values if they have never been set. I would wager some users are calling fig.subplots_adjust(**some_dict) which this request would change the behavior of in the case of an empty dictionary.

    It might be reasonable to reset the subplots params to the rcvalues in clf, but then we should do that for all of the rcparams that figure pulls in.

    We should add a flag to clf to disable the rcparam fetching. If we default the flag to True this is a minor API break (the figure will be in a slightly different state after clf that it used to be), but not one I am super worried about.

    Milestoned as 2.1 as this would be (in my view) a new feature, but if it gets done it would not be hard to convince me it should be back ported to 2.0.

    The exact work here is:

    • sort out which rcParams are consulted while creating a Figure object
    • add a flag to clf (and it's aliases) to optionally re-consult those values

    I think most of the effort will be tracking down all of the rcParams used.

  5. changed the title [-]changing subplot margins with style.use() requires window close() for effect[/-] [+]consult rcParams for Figures on `fig.clf`[/+] on Nov 9, 2016
  6. kaufman commented on Nov 9, 2016

    @kaufman
    ContributorAuthor

    I like this plan.

  7. modified the milestones: , on Sep 24, 2017
  8. added
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    on Oct 16, 2017
  9. added a commit that references this issue on Oct 29, 2017
  10. NNiehof commented on Oct 29, 2017

    @NNiehof

    Hello, I'm interested in contributing to matplotlib, and this seemed like a good way to start! I've made the requested changes (see #9622). I'd like to ask for a few hints if that's alright. When I try to recompile matplotlib with my changes, the newly installed version doesn't seem to have my changes. I'm working in a conda environment (in Windows 7), from which I've removed matplotlib. Then installed it again with conda install --use-local matplotlib, which successfully installs it, but apparently without the changes I've made. Do you have any advice on how to properly recompile and test, for each new change? I would much appreciate it.

  11. jklymak commented on Oct 30, 2017

    @jklymak
    Member

    Hi @NNiehof. I use pip as described in the developer guide in the docs. You’ll also find very helpful instructions for how to use git and style guides etc. Good luck!

  12. NNiehof commented on Oct 31, 2017

    @NNiehof

    @jklymak Thanks, I'll give that another go. I spent most of my Saturday getting matplotlib to install from source, the pip method didn't work then, because the dependencies and virtual environment weren't set up properly yet. Maybe now that's sorted out, building with pip as in the docs will work.

  13. afvincent commented on Oct 31, 2017

    @afvincent
    Contributor

    @NNiehof Just in case you don't already know that it exists: if you are struggling on a technical point, the Matplotlib gitter channel is (sometimes) more reactive that the issue tracker. Hopefully you won't need it ;).

  14. NNiehof commented on Oct 31, 2017

    @NNiehof
  15. removed
    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    on Dec 4, 2022
  16. tacaswell commented on Dec 4, 2022

    @tacaswell
    Member

    There is a slightly bigger discussion going on over what clear should mean, I have removed both the easy and good first issues labels as while the technical work is straight forward, there are some conceptual issues that need to be sorted.

  17. github-actions commented on Dec 6, 2023

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  18. added
    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.
    on Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …New featurestatus: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions