@@ -226,10 +226,10 @@ def _set_ticks_on_axis_warn(*args, **kw):
226
226
227
227
class ColorbarAxes (Axes ):
228
228
"""
229
- Colorbar Axes are actually two axes, a parent axes that takes care of
229
+ ColorbarAxes packages two axes, a parent axes that takes care of
230
230
positioning the axes, and an inset_axes that takes care of the drawing,
231
231
labels, ticks, etc. The inset axes is used as a way to properly
232
- position the triangles ( or rectangles) that are used to indicate
232
+ position the extensions (triangles or rectangles) that are used to indicate
233
233
over/under colors.
234
234
235
235
Users should not normally instantiate this class, but it is the class
@@ -251,13 +251,8 @@ def __init__(self, parent):
251
251
# map some features to the parent so users have access...
252
252
self .parent_ax .tick_params = self .inner_ax .tick_params
253
253
254
- def get_position (self , original = False ):
255
- # inherited
256
- return self .parent_ax .get_position (original = original )
257
-
258
- def set_position (self , pos , which = 'both' ):
259
- # inherited
260
- self .parent_ax .set_position (pos , which = which )
254
+ for attr in ["get_position" , "set_position" , "set_aspect" ]:
255
+ setattr (self , attr , getattr (self .parent_ax , attr ))
261
256
262
257
def _set_inner_bounds (self , bounds ):
263
258
"""
@@ -266,9 +261,6 @@ def _set_inner_bounds(self, bounds):
266
261
self .inner_ax ._axes_locator = _TransformedBoundsLocator (
267
262
bounds , self .parent_ax .transAxes )
268
263
269
- def set_aspect (self , aspect , ** kwargs ):
270
- self .parent_ax .set_aspect (aspect , ** kwargs )
271
-
272
264
273
265
class _ColorbarSpine (mspines .Spine ):
274
266
def __init__ (self , axes ):
@@ -566,16 +558,14 @@ def _do_extends(self, extendlen):
566
558
"""
567
559
# extend lengths are fraction of the *inner* part of colorbar,
568
560
# not the total colorbar:
569
- el = extendlen [0 ] if self ._extend_lower () else 0
570
- eu = extendlen [1 ] if self ._extend_upper () else 0
571
- tot = eu + el + 1
572
- el = el / tot
573
- eu = eu / tot
561
+ elower = extendlen [0 ] if self ._extend_lower () else 0
562
+ eupper = extendlen [1 ] if self ._extend_upper () else 0
563
+ tot = eupper + elower + 1
564
+ elower = elower / tot
565
+ eupper = eupper / tot
574
566
width = 1 / tot
575
567
576
- bounds = np .array ([0.0 , 0.0 , 1.0 , 1.0 ])
577
- bounds [1 ] = el
578
- bounds [3 ] = width
568
+ bounds = np .array ([0.0 , elower , 1.0 , width ])
579
569
580
570
# make the inner axes smaller to make room for the extend rectangle
581
571
top = bounds [1 ] + bounds [3 ]
@@ -605,9 +595,9 @@ def _do_extends(self, extendlen):
605
595
hatches = [None ]
606
596
if self ._extend_lower :
607
597
if not self .extendrect :
608
- xy = np .array ([[0.5 , 0 ], [1 , el ], [0 , el ]])
598
+ xy = np .array ([[0.5 , 0 ], [1 , elower ], [0 , elower ]])
609
599
else :
610
- xy = np .array ([[0 , 0 ], [1. , 0 ], [1 , el ], [0 , el ]])
600
+ xy = np .array ([[0 , 0 ], [1. , 0 ], [1 , elower ], [0 , elower ]])
611
601
if self .orientation == 'horizontal' :
612
602
xy = xy [:, ::- 1 ]
613
603
color = self .cmap (self .norm (self ._values [0 ]))
@@ -618,9 +608,9 @@ def _do_extends(self, extendlen):
618
608
self .ax .parent_ax .add_patch (patch )
619
609
if self ._extend_upper :
620
610
if not self .extendrect :
621
- xy = np .array ([[0.5 , 1 ], [1 , 1 - eu ], [0 , 1 - eu ]])
611
+ xy = np .array ([[0.5 , 1 ], [1 , 1 - eupper ], [0 , 1 - eupper ]])
622
612
else :
623
- xy = np .array ([[0 , 1 ], [1 , 1 ], [1 , 1 - eu ], [0 , 1 - eu ]])
613
+ xy = np .array ([[0 , 1 ], [1 , 1 ], [1 , 1 - eupper ], [0 , 1 - eupper ]])
624
614
if self .orientation == 'horizontal' :
625
615
xy = xy [:, ::- 1 ]
626
616
color = self .cmap (self .norm (self ._values [- 1 ]))
@@ -663,14 +653,14 @@ def add_lines(self, levels, colors, linewidths, erase=True):
663
653
xy = np .stack ([X , Y ], axis = - 1 )
664
654
else :
665
655
xy = np .stack ([Y , X ], axis = - 1 )
666
- col = collections .LineCollection (xy , linewidths = linewidths )
656
+ col = collections .LineCollection (xy , linewidths = linewidths ,
657
+ colors = colors )
667
658
668
659
if erase and self .lines :
669
660
for lc in self .lines :
670
661
lc .remove ()
671
662
self .lines = []
672
663
self .lines .append (col )
673
- col .set_color (colors )
674
664
675
665
# make a clip path that is just a linewidth bigger than the axes...
676
666
fac = np .max (linewidths ) / 72
@@ -696,21 +686,9 @@ def update_ticks(self):
696
686
ax = self .ax
697
687
# Get the locator and formatter; defaults to self.locator if not None.
698
688
self ._get_ticker_locator_formatter ()
699
- #if (self.boundaries is not None and self.spacing == 'uniform'):
700
- if False :
701
- _log .debug ('Using fixed locator on colorbar' )
702
- ticks , ticklabels , offset_string = self ._ticker (self .locator ,
703
- self .formatter )
704
- self ._long_axis ().set_ticks (ticks )
705
- self ._long_axis ().set_ticklabels (ticklabels )
706
- fmt = self ._long_axis ().get_major_formatter ()
707
- fmt .set_offset_string (offset_string )
708
- else : # use auto locators...
709
- _log .debug ('Using auto colorbar locator %r on colorbar' ,
710
- self .locator )
711
- self ._long_axis ().set_major_locator (self .locator )
712
- self ._long_axis ().set_minor_locator (self .minorlocator )
713
- self ._long_axis ().set_major_formatter (self .formatter )
689
+ self ._long_axis ().set_major_locator (self .locator )
690
+ self ._long_axis ().set_minor_locator (self .minorlocator )
691
+ self ._long_axis ().set_major_formatter (self .formatter )
714
692
715
693
def _get_ticker_locator_formatter (self ):
716
694
"""
@@ -787,7 +765,8 @@ def set_ticklabels(self, ticklabels, update_ticks=True):
787
765
"""
788
766
Set tick labels.
789
767
790
- update_ticks kwarg has no effect.
768
+ update_ticks : bool, default: True
769
+ This keyword argument is ignored and will be be removed.
791
770
"""
792
771
if isinstance (self .locator , ticker .FixedLocator ):
793
772
self .formatter = ticker .FixedFormatter (ticklabels )
@@ -797,7 +776,7 @@ def set_ticklabels(self, ticklabels, update_ticks=True):
797
776
798
777
def minorticks_on (self ):
799
778
"""
800
- Turn the minor ticks of the colorbar .
779
+ Turn on colorbar minor ticks.
801
780
"""
802
781
self .ax .minorticks_on ()
803
782
self .minorlocator = self ._long_axis ().get_minor_locator ()
0 commit comments