Skip to content

added raise condition and grouped Tick constructor parameters #26037

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 5 commits into
base: main
Choose a base branch
from
Open
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
34 changes: 14 additions & 20 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import datetime
import functools
import logging
import warnings
from numbers import Real

import numpy as np
Expand Down Expand Up @@ -57,26 +58,12 @@
"""
def __init__(
self, axes, loc, *,
size=None, # points
width=None,
color=None,
tickdir=None,
pad=None,
labelsize=None,
labelcolor=None,
labelfontfamily=None,
zorder=None,
gridOn=None, # defaults to axes.grid depending on axes.grid.which
tick1On=True,
tick2On=True,
label1On=True,
label2On=False,
major=True,
labelrotation=0,
grid_color=None,
grid_linestyle=None,
grid_linewidth=None,
grid_alpha=None,
size=None, width=None, color=None, major=True, pad=None, zorder=None, # global
Copy link
Member

@timhoffm timhoffm Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The size in points info must stay.

I'd have a slight preference to keep the one-parameter-per-line format and reorder in there:

# global
size=None,  # points
width=None,
...
# tick props
tickdir=None,
...

But that's personal taste and not a blocker.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree about the size in points comment staying.

tickdir=None, tick1On=True, tick2On=True, # tick prop
labelsize=None, labelcolor=None, labelrotation=0, # label prop
labelfontfamily=None, label1On=True, label2On=False, # label prop
grid_color=None, grid_linestyle=None, grid_linewidth=None, # grid prop
grid_alpha=None, gridOn=None, # grid prop
**kwargs, # Other Line2D kwargs applied to gridlines.
):
"""
Expand Down Expand Up @@ -154,6 +141,13 @@
grid_alpha = mpl.rcParams["grid.alpha"]
grid_kw = {k[5:]: v for k, v in kwargs.items()}

remaining_kwargs = {
k: v for k, v in kwargs.items() if not k.startswith('grid_')}
if remaining_kwargs:
warnings.warn(

Check warning on line 147 in lib/matplotlib/axis.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/axis.py#L147

Added line #L147 was not covered by tests
f"Invalid kwargs (not starting with 'grid_'):{remaining_kwargs.keys()}"
)

self.tick1line = mlines.Line2D(
[], [],
color=color, linestyle="none", zorder=zorder, visible=tick1On,
Expand Down