@@ -1745,18 +1745,18 @@ def _parse_colorbar_filled(
1745
1745
ax .patch .set_facecolor ('none' ) # ignore axes.alpha application
1746
1746
1747
1747
# Handle default keyword args
1748
- if side in ('bottom' , 'top' ):
1748
+ if orientation is None :
1749
+ orientation = 'horizontal' if side in ('bottom' , 'top' ) else 'vertical'
1750
+ if orientation == 'horizontal' :
1749
1751
outside , inside = 'bottom' , 'top'
1750
1752
if side == 'top' :
1751
1753
outside , inside = inside , outside
1752
1754
ticklocation = _not_none (ticklocation , outside )
1753
- orientation = _not_none (orientation , 'horizontal' )
1754
1755
else :
1755
1756
outside , inside = 'left' , 'right'
1756
1757
if side == 'right' :
1757
1758
outside , inside = inside , outside
1758
1759
ticklocation = _not_none (ticklocation , outside )
1759
- orientation = _not_none (orientation , 'vertical' )
1760
1760
kwargs .update ({'orientation' : orientation , 'ticklocation' : ticklocation })
1761
1761
return ax , kwargs
1762
1762
@@ -1819,8 +1819,8 @@ def _parse_colorbar_inset(
1819
1819
# Handle default keyword args
1820
1820
if orientation is not None and orientation != 'horizontal' :
1821
1821
warnings ._warn_proplot (
1822
- f'Orientation for inset colorbars must be horizontal, '
1823
- f'ignoring orientation={ orientation !r} .'
1822
+ f'Orientation for inset colorbars must be horizontal. '
1823
+ f'Ignoring orientation={ orientation !r} .'
1824
1824
)
1825
1825
ticklocation = _not_none (tickloc = tickloc , ticklocation = ticklocation )
1826
1826
if ticklocation is not None and ticklocation != 'bottom' :
@@ -2833,6 +2833,12 @@ def colorbar(
2833
2833
# The queue option lets us successively append objects (e.g. line handles)
2834
2834
# to a list later used for colorbar levels. Same as legend.
2835
2835
loc = _not_none (loc = loc , location = location )
2836
+ orientation = kwargs .get ('orientation' , None )
2837
+ if orientation is not None : # possibly infer loc from orientation
2838
+ if orientation not in ('vertical' , 'horizontal' ):
2839
+ raise ValueError (f"Invalid colorbar orientation { orientation !r} . Must be 'vertical' or 'horizontal'." ) # noqa: E501
2840
+ if loc is None :
2841
+ loc = {'vertical' : 'right' , 'horizontal' : 'bottom' }[orientation ]
2836
2842
loc = _translate_loc (loc , 'colorbar' , default = rc ['colorbar.loc' ])
2837
2843
align = _translate_loc (align , 'panel' , default = 'center' , c = 'center' , center = 'center' ) # noqa: E501
2838
2844
kwargs = guides ._guide_kw_from_obj (mappable , 'colorbar' , kwargs )
0 commit comments