-
-
Notifications
You must be signed in to change notification settings - Fork 7.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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
konmenel
wants to merge
18
commits into
matplotlib:main
Choose a base branch
from
konmenel:fix-issue-13919
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
bffeb0a
Possible fix for issue #13919
konmenel 87726b6
fix flake warnings
konmenel e3d22aa
Resolve suggested changes
konmenel 536b52e
Add new validators in stub file
konmenel 397a2ad
make stub file arguments same as runtime
konmenel 87339d8
Add distinction for x and y axis in grid line options
konmenel 09a7346
fix flake8
konmenel 42e0054
Add What's New note
konmenel 39eef79
Extend `_val_or_rc` to support multiply names
konmenel a4e6f44
Fix linting for and _validate_linestyle_or_None to mypy allowlist
konmenel 9a2b2b2
Remove validate linestyle functions from stubtest allow list
konmenel c886330
Revert change to just grid.major/minor distinction in rcParams
konmenel cd3c260
Update What's New note and reduced example
konmenel 456034c
Add testing for `grid.major/minor.*` in rcParams
konmenel ca5a443
fix indentation and linting
konmenel b455d6b
Fix example description
konmenel 2cb99fc
Fix spelling
konmenel 6552586
Merge branch 'main' into fix-issue-13919
timhoffm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Separate styling options for major/minor grid line in rcParams | ||
-------------------------------------------------------------- | ||
|
||
Using :rc:`grid.major.*` or :rc:`grid.minor.*` will overwrite the value in | ||
:rc:`grid.*` for the major and minor gridlines, respectively. | ||
|
||
.. plot:: | ||
:include-source: true | ||
:alt: Modifying the gridlines using the new options `rcParams` | ||
|
||
import matplotlib as mpl | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
# Set visibility for major and minor gridlines | ||
mpl.rcParams["axes.grid"] = True | ||
mpl.rcParams["ytick.minor.visible"] = True | ||
mpl.rcParams["xtick.minor.visible"] = True | ||
mpl.rcParams["axes.grid.which"] = "both" | ||
|
||
# Using old old values to set both major and minor properties | ||
mpl.rcParams["grid.color"] = "red" | ||
mpl.rcParams["grid.linewidth"] = 1 | ||
|
||
# Overwrite some values for major and minor separately | ||
mpl.rcParams["grid.major.color"] = "black" | ||
mpl.rcParams["grid.major.linewidth"] = 2 | ||
mpl.rcParams["grid.minor.linestyle"] = ":" | ||
mpl.rcParams["grid.minor.alpha"] = 0.6 | ||
|
||
plt.plot([0, 1], [0, 1]) | ||
|
||
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The example is a bit heavy. This should be illustrative easy to grap. It should give an idea what you can do and how. It's not an exhaustive documentation of the feature. The rendered entry should fit on a (large) screen. Please boil down to one figure (you can have two Axes side by side if really needed) and take a subset of rcParams only.
Typically, one figure should be enough. Select a few parameters.