@@ -226,10 +226,10 @@ def _set_ticks_on_axis_warn(*args, **kw):
226226
227227class ColorbarAxes (Axes ):
228228 """
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
230230 positioning the axes, and an inset_axes that takes care of the drawing,
231231 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
233233 over/under colors.
234234
235235 Users should not normally instantiate this class, but it is the class
@@ -251,13 +251,8 @@ def __init__(self, parent):
251251 # map some features to the parent so users have access...
252252 self .parent_ax .tick_params = self .inner_ax .tick_params
253253
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 ))
261256
262257 def _set_inner_bounds (self , bounds ):
263258 """
@@ -266,9 +261,6 @@ def _set_inner_bounds(self, bounds):
266261 self .inner_ax ._axes_locator = _TransformedBoundsLocator (
267262 bounds , self .parent_ax .transAxes )
268263
269- def set_aspect (self , aspect , ** kwargs ):
270- self .parent_ax .set_aspect (aspect , ** kwargs )
271-
272264
273265class _ColorbarSpine (mspines .Spine ):
274266 def __init__ (self , axes ):
@@ -566,16 +558,14 @@ def _do_extends(self, extendlen):
566558 """
567559 # extend lengths are fraction of the *inner* part of colorbar,
568560 # 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
574566 width = 1 / tot
575567
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 ])
579569
580570 # make the inner axes smaller to make room for the extend rectangle
581571 top = bounds [1 ] + bounds [3 ]
@@ -605,9 +595,9 @@ def _do_extends(self, extendlen):
605595 hatches = [None ]
606596 if self ._extend_lower :
607597 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 ]])
609599 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 ]])
611601 if self .orientation == 'horizontal' :
612602 xy = xy [:, ::- 1 ]
613603 color = self .cmap (self .norm (self ._values [0 ]))
@@ -618,9 +608,9 @@ def _do_extends(self, extendlen):
618608 self .ax .parent_ax .add_patch (patch )
619609 if self ._extend_upper :
620610 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 ]])
622612 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 ]])
624614 if self .orientation == 'horizontal' :
625615 xy = xy [:, ::- 1 ]
626616 color = self .cmap (self .norm (self ._values [- 1 ]))
@@ -663,14 +653,14 @@ def add_lines(self, levels, colors, linewidths, erase=True):
663653 xy = np .stack ([X , Y ], axis = - 1 )
664654 else :
665655 xy = np .stack ([Y , X ], axis = - 1 )
666- col = collections .LineCollection (xy , linewidths = linewidths )
656+ col = collections .LineCollection (xy , linewidths = linewidths ,
657+ colors = colors )
667658
668659 if erase and self .lines :
669660 for lc in self .lines :
670661 lc .remove ()
671662 self .lines = []
672663 self .lines .append (col )
673- col .set_color (colors )
674664
675665 # make a clip path that is just a linewidth bigger than the axes...
676666 fac = np .max (linewidths ) / 72
@@ -696,21 +686,9 @@ def update_ticks(self):
696686 ax = self .ax
697687 # Get the locator and formatter; defaults to self.locator if not None.
698688 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 )
714692
715693 def _get_ticker_locator_formatter (self ):
716694 """
@@ -787,7 +765,8 @@ def set_ticklabels(self, ticklabels, update_ticks=True):
787765 """
788766 Set tick labels.
789767
790- update_ticks kwarg has no effect.
768+ update_ticks : bool, default: True
769+ This keyword argument is ignored and will be be removed.
791770 """
792771 if isinstance (self .locator , ticker .FixedLocator ):
793772 self .formatter = ticker .FixedFormatter (ticklabels )
@@ -797,7 +776,7 @@ def set_ticklabels(self, ticklabels, update_ticks=True):
797776
798777 def minorticks_on (self ):
799778 """
800- Turn the minor ticks of the colorbar .
779+ Turn on colorbar minor ticks.
801780 """
802781 self .ax .minorticks_on ()
803782 self .minorlocator = self ._long_axis ().get_minor_locator ()
0 commit comments