Skip to content

[ENH]: Add zorder (grid, scatter, line, etc) in rcParams #29699

Open

Description

@JosephBARBIERDARNAL

Problem

Hi!

I'm working on rcParams and I'd really like it to be possible to control the default zorder of certain elements. The more the better, but being able to control the zorder specifically for grid, lines, scatter and bars would be great!

Is that possible?

Also, I'm willing to open a PR for this as long as it doesn't require a deep understanding of the inner workings of matplotlib.

Proposed solution

/

Activity

  1. JosephBARBIERDARNAL commented on Mar 3, 2025

    @JosephBARBIERDARNAL
    ContributorAuthor

    Note: more generally, I have a list of other things I'd like to see in rcParams.

  2. story645 commented on May 7, 2025

    @story645
    Member

    @JosephBARBIERDARNAL one of the things we've been discussing on and off is what our rcparams spec should even be - should it migrate to Python or json or the like (a good proportion of https://matplotlib.org/devdocs/devel/MEP/index.html)

    So might be worth thinking of this from that broader picture given that as far as I can see, this proposal would entail adding zorder to a bunch of properties (lines.zorder, etc)/

  3. JosephBARBIERDARNAL commented on May 9, 2025

    @JosephBARBIERDARNAL
    ContributorAuthor

    @story645 Would such a PR be welcome in the current rcParams structure, or should I wait until the spec changes are more finalized?

    If it helps, from the user's point of view, rcParams is really intuitive and I don't know what other specifications would add. The only thing that I feel could be improved is the matplotlibrc file, which I've always found confusing.

  4. tacaswell commented on May 9, 2025

    @tacaswell
    Member

    We have been relatively permissive about adding new rcparams when there has been a use case (we grow one or two per release). I suspect we would merge a PR adding the 4 listed zorder controls.

  5. JosephBARBIERDARNAL commented on May 9, 2025

    @JosephBARBIERDARNAL
    ContributorAuthor

    Great! Any pointers on how to add something to rcParams would be much appreciated (a PR that does this might actually work, I'll try to find one).

  6. tacaswell commented on May 9, 2025

    @tacaswell
    Member

    #18715 is a reasonable template.

  7. JosephBARBIERDARNAL commented on May 9, 2025

    @JosephBARBIERDARNAL
    ContributorAuthor

    Perfect, thanks

  8. story645 commented on May 9, 2025

    @story645
    Member

    The only thing that I feel could be improved is the matplotlibrc file, which I've always found confusing.

    how? what kinda things would make it easier for you?

  9. timhoffm commented on May 9, 2025

    @timhoffm
    Member

    The current zorder values are collected here: https://matplotlib.org/stable/gallery/misc/zorder_demo.html#zorder-demo.

    If we start making them configurable, we should do all

    image.zorder: 0
    patch.zorder: 1
    line.zorder: 2
    text.zorder: 3
    legend.zorder: 5
    

    The majortick zorder is currently line.zorder + 0.01. We could leave that for a start, or also think about making it configureable. Same with grid.zorder.

  10. JosephBARBIERDARNAL commented on May 10, 2025

    @JosephBARBIERDARNAL
    ContributorAuthor

    how? what kinda things would make it easier for you?

    It's more than that I don't understand why users should even be aware of this file. When looking at this in the documentation, it suggests that we can modify values in it to customize a plot, but at the same time the top of the file is ## NOTE FOR END USERS: DO NOT EDIT THIS FILE!

    From what I understand, rcParams is the only thing that users should be worried about, both in terms of ease of use and reproductibility (since I assume the matplotlibrc file is not meant to be versioned).

    Maybe this documentation is meant for matplotlib developers, but it's not obvious.

    What I like about this page in the documentation is that it contains all the rcParams parameters clearly defined.

  11. rcomer commented on May 10, 2025

    @rcomer
    Member

    the top of the file is ## NOTE FOR END USERS: DO NOT EDIT THIS FILE!

    The following lines state that users should make a copy of the file and edit that. Is there a way you think we could make that more obvious?

  12. JosephBARBIERDARNAL commented on May 10, 2025

    @JosephBARBIERDARNAL
    ContributorAuthor

    the top of the file is ## NOTE FOR END USERS: DO NOT EDIT THIS FILE!

    The following lines state that users should make a copy of the file and edit that. Is there a way you think we could make that more obvious?

    I just realised I'd misread it, I thought it was NOT instead of NOTE.

    But maybe something like that would be more intuitive: ## DO NOT EDIT THIS FILE, MAKE A COPY FIRST

  13. story645 commented on May 11, 2025

    @story645
    Member

    But maybe something like that would be more intuitive: ## DO NOT EDIT THIS FILE, MAKE A COPY FIRST

    Wanna open that PR?

  14. JosephBARBIERDARNAL commented on May 11, 2025

    @JosephBARBIERDARNAL
    ContributorAuthor

    Wanna open that PR?

    Yes, here it is: #30037

  15. pamitabh commented on Dec 18, 2025

    @pamitabh

    Just a user here, I recently wanted to put the gridlines behind the plot (I strongly feel this should be the default option!) but failed to do so. Online search leads to this popular stackoverflow post which suggests plt.rc('axes', axisbelow=True) which doesn't work anymore.

    So, having an option to control the zorder of the grid via rcParams would be great!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions