Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ae511a

Browse files
committed
Make functions param to secondary_x/yaxis not keyword-only.
I suspect the parameter was made keyword-only because the originally planned signature was `secondary_xaxis(location, forward=..., inverse=...)` where the keywords actually add some semantics (though that signature overall seems worse); however, for a single `functions` parameter, having to type an extra `functions=` in the call doesn't help the reader much (either they know what secondary_x/yaxis does, in which case the explicit kwarg doesn't matter, or they don't, in which case the kwarg name hardly helps)... and is a bit annoying. See the modified gallery entry, for example.
1 parent eb62d69 commit 7ae511a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

galleries/users_explain/quick_start.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ def my_plotter(ax, data1, data2, param_dict):
496496

497497
ax3.plot(t, s)
498498
ax3.set_xlabel('Angle [rad]')
499-
ax4 = ax3.secondary_xaxis('top', functions=(np.rad2deg, np.deg2rad))
499+
ax4 = ax3.secondary_xaxis('top', (np.rad2deg, np.deg2rad))
500500
ax4.set_xlabel('Angle [°]')
501501

502502
# %%

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ def indicate_inset_zoom(self, inset_ax, **kwargs):
570570
return self.indicate_inset(rect, inset_ax, **kwargs)
571571

572572
@_docstring.dedent_interpd
573-
def secondary_xaxis(self, location, *, functions=None, transform=None, **kwargs):
573+
def secondary_xaxis(self, location, functions=None, *, transform=None, **kwargs):
574574
"""
575575
Add a second x-axis to this `~.axes.Axes`.
576576
@@ -624,7 +624,7 @@ def invert(x):
624624
return secondary_ax
625625

626626
@_docstring.dedent_interpd
627-
def secondary_yaxis(self, location, *, functions=None, transform=None, **kwargs):
627+
def secondary_yaxis(self, location, functions=None, *, transform=None, **kwargs):
628628
"""
629629
Add a second y-axis to this `~.axes.Axes`.
630630

lib/matplotlib/axes/_axes.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,24 @@ class Axes(_AxesBase):
8888
def secondary_xaxis(
8989
self,
9090
location: Literal["top", "bottom"] | float,
91-
*,
9291
functions: tuple[
9392
Callable[[ArrayLike], ArrayLike], Callable[[ArrayLike], ArrayLike]
9493
]
9594
| Transform
9695
| None = ...,
96+
*,
9797
transform: Transform | None = ...,
9898
**kwargs
9999
) -> SecondaryAxis: ...
100100
def secondary_yaxis(
101101
self,
102102
location: Literal["left", "right"] | float,
103-
*,
104103
functions: tuple[
105104
Callable[[ArrayLike], ArrayLike], Callable[[ArrayLike], ArrayLike]
106105
]
107106
| Transform
108107
| None = ...,
108+
*,
109109
transform: Transform | None = ...,
110110
**kwargs
111111
) -> SecondaryAxis: ...

0 commit comments

Comments
 (0)