@@ -565,10 +565,11 @@ def _add_solids(self, X, Y, C):
565565
566566 self .solids = col
567567 if self .drawedges :
568- self .dividers = collections .LineCollection (self ._edges (X ,Y ),
569- colors = (mpl .rcParams ['axes.edgecolor' ],),
570- linewidths = (0.5 * mpl .rcParams ['axes.linewidth' ],),
571- )
568+ self .dividers = collections .LineCollection (
569+ self ._edges (X ,Y ),
570+ colors = (mpl .rcParams ['axes.edgecolor' ],),
571+ linewidths = (0.5 * mpl .rcParams ['axes.linewidth' ],),
572+ )
572573 self .ax .add_collection (self .dividers )
573574 else :
574575 self .dividers = None
@@ -577,22 +578,16 @@ def add_lines(self, levels, colors, linewidths):
577578 '''
578579 Draw lines on the colorbar. It deletes preexisting lines.
579580 '''
580- del self .lines
581-
582- N = len (levels )
583- x = np .array ([1.0 , 2.0 ])
584- X , Y = np .meshgrid (x ,levels )
581+ X , Y = np .meshgrid ([1 , 2 ], levels )
585582 if self .orientation == 'vertical' :
586- xy = [ list ( zip ( X [ i ] , Y [ i ])) for i in range ( N )]
583+ xy = np . stack ([ X , Y ], axis = - 1 )
587584 else :
588- xy = [list (zip (Y [i ], X [i ])) for i in range (N )]
589- col = collections .LineCollection (xy , linewidths = linewidths ,
590- )
585+ xy = np .stack ([Y , X ], axis = - 1 )
586+ col = collections .LineCollection (xy , linewidths = linewidths )
591587 self .lines = col
592588 col .set_color (colors )
593589 self .ax .add_collection (col )
594590
595-
596591 def _select_locator (self , formatter ):
597592 '''
598593 select a suitable locator
0 commit comments