Skip to content

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

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

Open
JosephBARBIERDARNAL opened this issue Mar 3, 2025 · 14 comments
Open

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

JosephBARBIERDARNAL opened this issue Mar 3, 2025 · 14 comments

Comments

@JosephBARBIERDARNAL
Copy link
Contributor

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

/

@JosephBARBIERDARNAL
Copy link
Contributor Author

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

@story645
Copy link
Member

story645 commented May 7, 2025

@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)/

@JosephBARBIERDARNAL
Copy link
Contributor Author

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

@tacaswell
Copy link
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.

@JosephBARBIERDARNAL
Copy link
Contributor Author

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

@tacaswell
Copy link
Member

#18715 is a reasonable template.

@JosephBARBIERDARNAL
Copy link
Contributor Author

Perfect, thanks

@story645
Copy link
Member

story645 commented May 9, 2025

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?

@timhoffm
Copy link
Member

timhoffm commented May 9, 2025

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.

@JosephBARBIERDARNAL
Copy link
Contributor Author

JosephBARBIERDARNAL commented May 10, 2025

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.

@rcomer
Copy link
Member

rcomer commented May 10, 2025

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?

@JosephBARBIERDARNAL
Copy link
Contributor Author

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

@story645
Copy link
Member

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

Wanna open that PR?

@JosephBARBIERDARNAL
Copy link
Contributor Author

Wanna open that PR?

Yes, here it is: #30037

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

No branches or pull requests

5 participants