@@ -489,19 +489,21 @@ def __init__(self, fig,
489489
490490 def _update_locators (self ):
491491
492+ cb_mode = self ._colorbar_mode
493+ cb_location = self ._colorbar_location
494+
492495 h = []
493496 v = []
494497
495498 h_ax_pos = []
496499 h_cb_pos = []
497- if (self ._colorbar_mode == "single" and
498- self ._colorbar_location in ('left' , 'bottom' )):
499- if self ._colorbar_location == "left" :
500+ if cb_mode == "single" and cb_location in ("left" , "bottom" ):
501+ if cb_location == "left" :
500502 sz = self ._nrows * Size .AxesX (self .axes_llc )
501503 h .append (Size .from_any (self ._colorbar_size , sz ))
502504 h .append (Size .from_any (self ._colorbar_pad , sz ))
503505 locator = self ._divider .new_locator (nx = 0 , ny = 0 , ny1 = - 1 )
504- elif self . _colorbar_location == "bottom" :
506+ elif cb_location == "bottom" :
505507 sz = self ._ncols * Size .AxesY (self .axes_llc )
506508 v .append (Size .from_any (self ._colorbar_size , sz ))
507509 v .append (Size .from_any (self ._colorbar_pad , sz ))
@@ -521,21 +523,19 @@ def _update_locators(self):
521523 sz = Size .AxesX (self .axes_all [0 ],
522524 aspect = "axes" , ref_ax = self .axes_all [0 ])
523525
524- if (self . _colorbar_mode == "each" or
525- ( self . _colorbar_mode == 'edge' and
526- col == 0 )) and self . _colorbar_location == "left" :
526+ if (cb_location == "left"
527+ and ( cb_mode == "each"
528+ or ( cb_mode == "edge" and col == 0 ))) :
527529 h_cb_pos .append (len (h ))
528530 h .append (Size .from_any (self ._colorbar_size , sz ))
529531 h .append (Size .from_any (self ._colorbar_pad , sz ))
530532
531533 h_ax_pos .append (len (h ))
532-
533534 h .append (sz )
534535
535- if ((self ._colorbar_mode == "each" or
536- (self ._colorbar_mode == 'edge' and
537- col == self ._ncols - 1 )) and
538- self ._colorbar_location == "right" ):
536+ if (cb_location == "right"
537+ and (cb_mode == "each"
538+ or (cb_mode == "edge" and col == self ._ncols - 1 ))):
539539 h .append (Size .from_any (self ._colorbar_pad , sz ))
540540 h_cb_pos .append (len (h ))
541541 h .append (Size .from_any (self ._colorbar_size , sz ))
@@ -552,20 +552,19 @@ def _update_locators(self):
552552 sz = Size .AxesY (self .axes_all [0 ],
553553 aspect = "axes" , ref_ax = self .axes_all [0 ])
554554
555- if (self . _colorbar_mode == "each" or
556- ( self . _colorbar_mode == 'edge' and
557- row == 0 )) and self . _colorbar_location == "bottom" :
555+ if (cb_location == "bottom"
556+ and ( cb_mode == "each"
557+ or ( cb_mode == "edge" and row == 0 ))) :
558558 v_cb_pos .append (len (v ))
559559 v .append (Size .from_any (self ._colorbar_size , sz ))
560560 v .append (Size .from_any (self ._colorbar_pad , sz ))
561561
562562 v_ax_pos .append (len (v ))
563563 v .append (sz )
564564
565- if ((self ._colorbar_mode == "each" or
566- (self ._colorbar_mode == 'edge' and
567- row == self ._nrows - 1 )) and
568- self ._colorbar_location == "top" ):
565+ if (cb_location == "top"
566+ and (cb_mode == "each"
567+ or (cb_mode == "edge" and row == self ._nrows - 1 ))):
569568 v .append (Size .from_any (self ._colorbar_pad , sz ))
570569 v_cb_pos .append (len (v ))
571570 v .append (Size .from_any (self ._colorbar_size , sz ))
@@ -576,51 +575,49 @@ def _update_locators(self):
576575 ny = v_ax_pos [self ._nrows - 1 - row ])
577576 self .axes_all [i ].set_axes_locator (locator )
578577
579- if self . _colorbar_mode == "each" :
580- if self . _colorbar_location in ("right" , "left" ):
578+ if cb_mode == "each" :
579+ if cb_location in ("right" , "left" ):
581580 locator = self ._divider .new_locator (
582581 nx = h_cb_pos [col ], ny = v_ax_pos [self ._nrows - 1 - row ])
583582
584- elif self . _colorbar_location in ("top" , "bottom" ):
583+ elif cb_location in ("top" , "bottom" ):
585584 locator = self ._divider .new_locator (
586585 nx = h_ax_pos [col ], ny = v_cb_pos [self ._nrows - 1 - row ])
587586
588587 self .cbar_axes [i ].set_axes_locator (locator )
589- elif self ._colorbar_mode == 'edge' :
590- if ((self ._colorbar_location == 'left' and col == 0 ) or
591- (self ._colorbar_location == 'right'
592- and col == self ._ncols - 1 )):
588+ elif cb_mode == "edge" :
589+ if (cb_location == "left" and col == 0
590+ or cb_location == "right" and col == self ._ncols - 1 ):
593591 locator = self ._divider .new_locator (
594592 nx = h_cb_pos [0 ], ny = v_ax_pos [self ._nrows - 1 - row ])
595593 self .cbar_axes [row ].set_axes_locator (locator )
596- elif ((self ._colorbar_location == 'bottom' and
597- row == self ._nrows - 1 ) or
598- (self ._colorbar_location == 'top' and row == 0 )):
594+ elif (cb_location == "bottom" and row == self ._nrows - 1
595+ or cb_location == "top" and row == 0 ):
599596 locator = self ._divider .new_locator (nx = h_ax_pos [col ],
600597 ny = v_cb_pos [0 ])
601598 self .cbar_axes [col ].set_axes_locator (locator )
602599
603- if self . _colorbar_mode == "single" :
604- if self . _colorbar_location == "right" :
600+ if cb_mode == "single" :
601+ if cb_location == "right" :
605602 sz = self ._nrows * Size .AxesX (self .axes_llc )
606603 h .append (Size .from_any (self ._colorbar_pad , sz ))
607604 h .append (Size .from_any (self ._colorbar_size , sz ))
608605 locator = self ._divider .new_locator (nx = - 2 , ny = 0 , ny1 = - 1 )
609- elif self . _colorbar_location == "top" :
606+ elif cb_location == "top" :
610607 sz = self ._ncols * Size .AxesY (self .axes_llc )
611608 v .append (Size .from_any (self ._colorbar_pad , sz ))
612609 v .append (Size .from_any (self ._colorbar_size , sz ))
613610 locator = self ._divider .new_locator (nx = 0 , nx1 = - 1 , ny = - 2 )
614- if self . _colorbar_location in ("right" , "top" ):
611+ if cb_location in ("right" , "top" ):
615612 for i in range (self .ngrids ):
616613 self .cbar_axes [i ].set_visible (False )
617614 self .cbar_axes [0 ].set_axes_locator (locator )
618615 self .cbar_axes [0 ].set_visible (True )
619- elif self . _colorbar_mode == "each" :
616+ elif cb_mode == "each" :
620617 for i in range (self .ngrids ):
621618 self .cbar_axes [i ].set_visible (True )
622- elif self . _colorbar_mode == "edge" :
623- if self . _colorbar_location in (' right' , ' left' ):
619+ elif cb_mode == "edge" :
620+ if cb_location in (" right" , " left" ):
624621 count = self ._nrows
625622 else :
626623 count = self ._ncols
0 commit comments