Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Support individual styling of major and minor grid through rcParams#29481
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join uson gitter for real-time discussion.
For details on testing, writing docs, and our review process, please seethe developer guide
We strive to be a welcoming and open project. Please follow ourCode of Conduct.
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 the PR. The solution is surprisingly simple. I would have thought that there are more complications because of the concurrent settings and the need for backward compatibility.
The only improvement needed is the clearer distinction on the color and linewidth parameter values between "none" andNone
.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
One related aspect to think about: Do we anticipate that we'll need a distinction between x and y axis as well? Because if so, we should directly introduce these. |
The `*_or_None` validators have accepted any capitalization of thestring "none" as input. This is overly permissive andwill likely lead to conflicts in the future because we cannotdistinguish between resolving to `None` and `"none"` which may be needfor some parameters in the future.Inspired bymatplotlib#29481.
konmenel commentedJan 27, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I made the suggested changes.
Can you clarify what you meant by "a distinction between x and y axis"? Do you mean something like rcParams["grid.major.xaxis.linestyle"]=":"rcParams["grid.major.yaxis.linestyle"]="-" |
The `*_or_None` validators have accepted any capitalization of thestring "none" as input. This is overly permissive andwill likely lead to conflicts in the future because we cannotdistinguish between resolving to `None` and `"none"` which may be needfor some parameters in the future.Inspired bymatplotlib#29481.
konmenel commentedJan 27, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Sorry I forgot to update the ".pyi" file |
Basically yes. Exact spelling t.b.d. |
Uh oh!
There was an error while loading.Please reload this page.
konmenel commentedJan 27, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I think this is possible however it might look "ugly". The change will require the One possible way is by accessing the Another way is to add an extra required argument to the constructor of Any thoughts on those? |
We already rely on matplotlib/lib/matplotlib/axis.py Lines 106 to 116 in3b329d9
It's ok to use that. Spelling: We have "xaxis", "xticks", "xscale" as axis-dependent names (but they are all also used in the python interface). We do not have any xgrid or similar names. Options:
None of them look like the obvious right choice to me. |
Out of the four, I prefer two:
I will try to implement the second one for now. I can change the key later. |
The `*_or_None` validators have accepted any capitalization of thestring "none" as input. This is overly permissive andwill likely lead to conflicts in the future because we cannotdistinguish between resolving to `None` and `"none"` which may be needfor some parameters in the future.Inspired bymatplotlib#29481.
I implemented the x and y axis distinction however I came across something that needs further clarification. Right now "grid.xaxis.major.linestyle" is a valid key but "grid.xaxis.linestyle" is not. Should it be a valid option as well? If so it is unclear which of "grid.major.linestyle"and "grid.xaxis.linestyle" should take precedence. |
No, we don't need "grid.xaxis.linestyle". If starting from scratch, I'd just have the granular settings "grid.xaxis.major.linestyle" etc. After all, these are advanced style configuration options, and if somebody cares to adapt them, it's ok to write out the details. We keep the high-level ones "grid.linestyle" for backward compatibility (and it is a nice convenience) but we don't need the middle-ground. |
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.
Looks good. Please add a What's New note according tohttps://matplotlib.org/devdocs/devel/api_changes.html#what-s-new-notes
Uh oh!
There was an error while loading.Please reload this page.
`_val_or_rc` now accept multiple rc names and return val or the first non-None value in rcParams. Returns last rc name if all other are None. Also, simplified code in `Tick` for grid lines creatation
Uh oh!
There was an error while loading.Please reload this page.
I fix the spelling so all tests should pass now. If there is anything else please let me know. |
carlosgmartin commentedMar 31, 2025
@timhoffm Any idea when this might be merged? |
This needs a second review by a core developer, and review time is scarce. However, this is flagged for 3.11 and I'm pretty sure it will get the attention in time for the next release. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
@QuLogic I have made the changes you suggested. If there is anything more I need to do, please let me know. |
stubtest is still complaining about |
Yes, I did it that way because this is how it is in the main branch. I never modified the function Do you want me to modify the function or revert the change in "ci/mypy-stubtest-allowlist.txt"? |
6e51bec
intomatplotlib:mainUh oh!
There was an error while loading.Please reload this page.
Thanks@konmenel! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again. |
PR summary
Possiblycloses#13919 issue. Additionally, PR#26121 also tried to solve the same issue but I understand that it is not backwards compatible and there haven't been any updates since 2023. My implementation should be backwards compatible.
I have tested the code with pytest. Some tests failed on my machine, but all were latex tests. The problem is probably my latex installation.
I also tested to code with a small python script that:
The results were identical and as expected.
Test
My test script:
Results
PR checklist