8000 Allow separate config of minor grid params in matplotlibrc. by RJTK · Pull Request #26121 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Allow separate config of minor grid params in matplotlibrc. #26121

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,24 @@ def __init__(
zorder = mlines.Line2D.zorder
self._zorder = zorder

if major:
grid_name = "grid"
else:
grid_name = "grid.minor"

if grid_color is None:
grid_color = mpl.rcParams["grid.color"]
grid_color = mpl.rcParams[f"{grid_name}.color"]
if grid_linestyle is None:
grid_linestyle = mpl.rcParams["grid.linestyle"]
grid_linestyle = mpl.rcParams[f"{grid_name}.linestyle"]
if grid_linewidth is None:
grid_linewidth = mpl.rcParams["grid.linewidth"]
grid_linewidth = mpl.rcParams[f"{grid_name}.linewidth"]
if grid_alpha is None and not mcolors._has_alpha_channel(grid_color):
# alpha precedence: kwarg > color alpha > rcParams['grid.alpha']
# Note: only resolve to rcParams if the color does not have alpha
# otherwise `grid(color=(1, 1, 1, 0.5))` would work like
# grid(color=(1, 1, 1, 0.5), alpha=rcParams['grid.alpha'])
# so the that the rcParams default would override color alpha.
grid_alpha = mpl.rcParams["grid.alpha"]
grid_alpha = mpl.rcParams[f"{grid_name}.alpha"]
grid_kw = {k[5:]: v for k, v in kwargs.items()}

self.tick1line = mlines.Line2D(
Expand Down
4 changes: 4 additions & 0 deletions lib/matplotlib/mpl-data/matplotlibrc
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@
#grid.linewidth: 0.8 # in points
#grid.alpha: 1.0 # transparency, between 0.0 and 1.0

#grid.minor.color: "#b0b0b0" # minor grid color
#grid.minor.linestyle: - # solid
#grid.minor.linewidth: 0.8 # in points
#grid.minor.alpha: 1.0 # transparency, between 0.0 and 1.0

## ***************************************************************************
## * LEGEND *
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,11 @@ def _convert_validator_spec(key, conv):
"grid.linewidth": validate_float, # in points
"grid.alpha": validate_float,

"grid.minor.color": validate_color, # minor grid color
"grid.minor.linestyle": _validate_linestyle, # solid
"grid.minor.linewidth": validate_float, # in points
"grid.minor.alpha": validate_float,

## figure props
# figure title
"figure.titlesize": validate_fontsize,
Expand Down
0