64
64
xloc, yloc : optional
65
65
Shorthands for `xspineloc`, `yspineloc`.
66
66
xspineloc, yspineloc : {'bottom', 'top', 'left', 'right', \
67
- 'both', 'neither', 'none', 'center ', 'zero'} , optional
68
- The x and y axis spine locations. Propagates to `tickloc` unless specified
69
- otherwise (if not ``'center'`` or ``'zero'``) .
67
+ 'both', 'neither', 'none', 'zero ', 'center'} or 2-tuple , optional
68
+ The x and y spine locations. Applied with `~matplotlib.spines.Spine.set_position`.
69
+ Propagates to `tickloc` unless specified otherwise .
70
70
xtickloc, ytickloc \
71
71
: {'bottom', 'top', 'left', 'right', 'both', 'neither', 'none'}, optional
72
72
Which x and y axis spines should have major and minor tick marks. Inherits from
@@ -735,12 +735,17 @@ def _update_locs(
735
735
# The tick and tick label sides for Cartesian axes
736
736
kw = {}
737
737
sides = ('bottom' , 'top' ) if x == 'x' else ('left' , 'right' )
738
+ sides_map = {'both' : sides , 'neither' : (), 'none' : (), None : None }
738
739
sides_active = tuple (side for side in sides if self .spines [side ].get_visible ())
739
- sides_dict = {None : None , 'both' : sides , 'none' : (), 'neither' : ()}
740
740
741
741
# The tick side(s)
742
742
# NOTE: Silently forbids adding ticks to sides with invisible spines
743
- ticklocs = sides_dict .get (tickloc , (tickloc ,))
743
+ ticklocs = sides_map .get (tickloc , (tickloc ,))
744
+ if ticklocs and any (loc not in sides for loc in ticklocs ):
745
+ raise ValueError (
746
+ f'Invalid tick mark location { tickloc !r} . Options are '
747
+ + ', ' .join (map (repr , sides + tuple (sides_map ))) + '.'
748
+ )
744
749
if ticklocs is not None :
745
750
kw .update ({side : side in ticklocs for side in sides })
746
751
kw .update (
@@ -751,7 +756,12 @@ def _update_locs(
751
756
752
757
# The tick label side(s). Make sure these only appear where ticks are
753
758
# NOTE: Silently forbids adding labels to sides with invisible ticks or spines
754
- ticklabellocs = sides_dict .get (ticklabelloc , (ticklabelloc ,))
759
+ ticklabellocs = sides_map .get (ticklabelloc , (ticklabelloc ,))
760
+ if ticklabellocs and any (loc not in sides for loc in ticklabellocs ):
761
+ raise ValueError (
762
+ f'Invalid tick label location { ticklabelloc !r} . Options are '
763
+ + ', ' .join (map (repr , sides + tuple (sides_map ))) + '.'
764
+ )
755
765
if ticklabellocs is not None :
756
766
kw .update ({'label' + side : (side in ticklabellocs ) for side in sides })
757
767
kw .update (
0 commit comments