8000 Merge pull request #12210 from timhoffm/axes-tick_params-checking · matplotlib/matplotlib@03b07fb · GitHub
[go: up one dir, main page]

Skip to content

Commit 03b07fb

Browse files
authored
Merge pull request #12210 from timhoffm/axes-tick_params-checking
Axes.tick_params() argument checking
2 parents 99eea61 + 2642831 commit 03b07fb

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Axes.tick_params argument checking
2+
``````````````````````````````````
3+
4+
`Axes.tick_params` silently did nothing when an invalid *axis* parameter was
5+
supplied. This behavior is changed to raise a ValueError instead.

lib/matplotlib/axes/_base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,6 +2949,8 @@ def tick_params(self, axis='both', **kwargs):
29492949
also be red. Gridlines will be red and translucent.
29502950
29512951
"""
2952+
if axis not in ['x', 'y', 'both']:
2953+
raise ValueError("axis must be one of 'x', 'y' or 'both'")
29522954
if axis in ['x', 'both']:
29532955
xkw = dict(kwargs)
29542956
xkw.pop('left', None)

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,10 @@ def tick_params(self, axis='both', **kwargs):
14121412
.. versionadded :: 1.1.0
14131413
This function was added, but not tested. Please report any bugs.
14141414
"""
1415-
super().tick_params(axis, **kwargs)
1415+
if axis not in ['x', 'y', 'z', 'both']:
1416+
raise ValueError("axis must be one of 'x', 'y', 'z' or 'both'")
1417+
if axis in ['x', 'y', 'both']:
1418+
super().tick_params(axis, **kwargs)
14161419
if axis in ['z', 'both']:
14171420
zkw = dict(kwargs)
14181421
zkw.pop('top', None)

0 commit comments

Comments
 (0)
0