52
52
``xscale=('cutoff', 100, 2)`` applies a `~proplot.scale.CutoffScale`.
53
53
xscale_kw, yscale_kw : dict-like, optional
54
54
The x and y axis scale settings. Passed to `~proplot.scale.Scale`.
55
- xspineloc, yspineloc \
56
- : {'bottom ', 'top ', 'left', 'right', 'both', 'neither ', 'center', 'zero'}, optional
55
+ xspineloc, yspineloc : {'bottom', 'top', 'left', 'right', \
56
+ 'both ', 'neither ', 'none ', 'center', 'zero'}, optional
57
57
The x and y axis spine locations.
58
58
xtickloc, ytickloc \
59
- : {'bottom', 'top', 'left', 'right', 'both', 'neither'}, optional
59
+ : {'bottom', 'top', 'left', 'right', 'both', 'neither', 'none' }, optional
60
60
Which x and y axis spines should have major and minor tick marks.
61
61
xticklabelloc, yticklabelloc \
62
- : {'bottom', 'top', 'left', 'right', 'both', 'neither'}, optional
62
+ : {'bottom', 'top', 'left', 'right', 'both', 'neither', 'none' }, optional
63
63
Which x and y axis spines should have major tick labels. Default
64
64
behavior is to inherit this from `xtickloc` and `ytickloc`.
65
65
xlabelloc, ylabelloc : {'bottom', 'top', 'left', 'right'}, optional
66
66
Which x and y axis spines should have axis labels. Default
67
67
behavior is to inherit this from `xticklabelloc` and `yticklabelloc`.
68
+ xoffsetloc, yoffsetloc : {'bottom', 'top', 'left', 'right'}, optional
69
+ Which x and y axis spines should have the axis offset indicator. Default
70
+ behavior is to inherit this from `xticklabelloc` and `yticklabelloc`.
68
71
xtickdir, ytickdir, tickdir : {'out', 'in', 'inout'}
69
72
Direction that major and minor tick marks point for the x and y axis.
70
73
Use `tickdir` to control both.
@@ -702,7 +705,9 @@ def _update_spines(self, x, *, loc=None, bounds=None):
702
705
if bounds is not None :
703
706
spine .set_bounds (* bounds )
704
707
705
- def _update_locs (self , x , * , tickloc = None , ticklabelloc = None , labelloc = None ):
708
+ def _update_locs (
709
+ self , x , * , tickloc = None , ticklabelloc = None , labelloc = None , offsetloc = None
710
+ ):
706
711
"""
707
712
Update the tick, tick label, and axis label locations.
708
713
"""
@@ -713,12 +718,18 @@ def _update_locs(self, x, *, tickloc=None, ticklabelloc=None, labelloc=None):
713
718
sides_dict = {None : None , 'both' : sides , 'none' : (), 'neither' : ()}
714
719
715
720
# The tick side(s)
721
+ # NOTE: Silently forbids adding ticks to sides with invisible spines
716
722
ticklocs = sides_dict .get (tickloc , (tickloc ,))
717
723
if ticklocs is not None :
718
724
kw .update ({side : side in ticklocs for side in sides })
719
- kw .update ({side : False for side in sides if side not in sides_active })
725
+ kw .update (
726
+ {
727
+ side : False for side in sides if side not in sides_active
728
+ }
729
+ )
720
730
721
731
# The tick label side(s). Make sure these only appear where ticks are
732
+ # NOTE: Silently forbids adding labels to sides with invisible ticks or spines
722
733
ticklabellocs = sides_dict .get (ticklabelloc , (ticklabelloc ,))
723
734
if ticklabellocs is not None :
724
735
kw .update ({'label' + side : (side in ticklabellocs ) for side in sides })
@@ -731,21 +742,25 @@ def _update_locs(self, x, *, tickloc=None, ticklabelloc=None, labelloc=None):
731
742
)
732
743
733
744
# The axis label side(s)
734
- if labelloc is None :
735
- if ticklocs is not None :
736
- options = tuple (_ for _ in sides if _ in ticklocs and _ in sides_active )
737
- if len (options ) == 1 :
738
- labelloc = options [0 ]
745
+ # NOTE: Silently forbids adding labels and offsets to sides with missing spines
746
+ if ticklocs is not None :
747
+ options = tuple (_ for _ in sides if _ in ticklocs and _ in sides_active )
748
+ if len (options ) == 1 :
749
+ labelloc = _not_none (labelloc , options [0 ])
750
+ offsetloc = _not_none (offsetloc , options [0 ])
739
751
if labelloc is not None and labelloc not in sides :
740
752
raise ValueError (
741
753
f'Invalid label location { labelloc !r} . Options are '
742
754
+ ', ' .join (map (repr , sides )) + '.'
743
755
)
744
756
745
757
# Apply the tick, tick label, and label locations
758
+ axis = getattr (self , x + 'axis' )
746
759
self .tick_params (axis = x , which = 'both' , ** kw )
747
760
if labelloc is not None :
748
- getattr (self , x + 'axis' ).set_label_position (labelloc )
761
+ axis .set_label_position (labelloc )
762
+ if offsetloc is not None :
763
+ axis .set_offset_position (offsetloc )
749
764
750
765
@warnings ._rename_kwargs ('0.9' , xloc = 'xspineloc' , yloc = 'yspineloc' )
751
766
@docstring ._snippet_manager
@@ -756,6 +771,7 @@ def format(
756
771
xspineloc = None , yspineloc = None ,
757
772
xtickloc = None , ytickloc = None , fixticks = False ,
758
773
xlabelloc = None , ylabelloc = None ,
774
+ xoffsetloc = None , yoffsetloc = None ,
759
775
xticklabelloc = None , yticklabelloc = None ,
760
776
xtickdir = None , ytickdir = None ,
761
777
xgrid = None , ygrid = None ,
@@ -863,10 +879,12 @@ def format(
863
879
xticklabelloc = _not_none (xticklabelloc , xtickloc )
864
880
if xticklabelloc in ('bottom' , 'top' ):
865
881
xlabelloc = _not_none (xlabelloc , xticklabelloc )
882
+ xoffsetloc = _not_none (xoffsetloc , xticklabelloc )
866
883
if ytickloc != 'both' : # then infer others
867
884
yticklabelloc = _not_none (yticklabelloc , ytickloc )
868
885
if yticklabelloc in ('left' , 'right' ):
869
886
ylabelloc = _not_none (ylabelloc , yticklabelloc )
887
+ ylabelloc = _not_none (yoffsetloc , yticklabelloc )
870
888
871
889
# Loop over axes
872
890
for (
@@ -877,6 +895,7 @@ def format(
877
895
margin , bounds ,
878
896
tickloc , spineloc ,
879
897
ticklabelloc , labelloc ,
898
+ offsetloc ,
880
899
grid , gridminor ,
881
900
tickminor , minorlocator ,
882
901
min_ , max_ , lim ,
@@ -896,6 +915,7 @@ def format(
896
915
(xmargin , ymargin ), (xbounds , ybounds ),
897
916
(xtickloc , ytickloc ), (xspineloc , yspineloc ),
898
917
(xticklabelloc , yticklabelloc ), (xlabelloc , ylabelloc ),
918
+ (xoffsetloc , yoffsetloc ),
899
919
(xgrid , ygrid ), (xgridminor , ygridminor ),
900
920
(xtickminor , ytickminor ), (xminorlocator , yminorlocator ),
901
921
(xmin , ymin ), (xmax , ymax ), (xlim , ylim ),
@@ -934,7 +954,8 @@ def format(
934
954
935
955
# Axis tick settings
936
956
self ._update_locs (
937
- x , tickloc = tickloc , ticklabelloc = ticklabelloc , labelloc = labelloc
957
+ x , tickloc = tickloc , ticklabelloc = ticklabelloc ,
958
+ labelloc = labelloc , offsetloc = offsetloc ,
938
959
)
939
960
self ._update_rotation (
940
961
x , rotation = rotation
0 commit comments