@@ -489,19 +489,21 @@ def __init__(self, fig,
489
489
490
490
def _update_locators (self ):
491
491
492
+ cb_mode = self ._colorbar_mode
493
+ cb_location = self ._colorbar_location
494
+
492
495
h = []
493
496
v = []
494
497
495
498
h_ax_pos = []
496
499
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" :
500
502
sz = self ._nrows * Size .AxesX (self .axes_llc )
501
503
h .append (Size .from_any (self ._colorbar_size , sz ))
502
504
h .append (Size .from_any (self ._colorbar_pad , sz ))
503
505
locator = self ._divider .new_locator (nx = 0 , ny = 0 , ny1 = - 1 )
504
- elif self . _colorbar_location == "bottom" :
506
+ elif cb_location == "bottom" :
505
507
sz = self ._ncols * Size .AxesY (self .axes_llc )
506
508
v .append (Size .from_any (self ._colorbar_size , sz ))
507
509
v .append (Size .from_any (self ._colorbar_pad , sz ))
@@ -521,21 +523,19 @@ def _update_locators(self):
521
523
sz = Size .AxesX (self .axes_all [0 ],
522
524
aspect = "axes" , ref_ax = self .axes_all [0 ])
523
525
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 ))) :
527
529
h_cb_pos .append (len (h ))
528
530
h .append (Size .from_any (self ._colorbar_size , sz ))
529
531
h .append (Size .from_any (self ._colorbar_pad , sz ))
530
532
531
533
h_ax_pos .append (len (h ))
532
-
533
534
h .append (sz )
534
535
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 ))):
539
539
h .append (Size .from_any (self ._colorbar_pad , sz ))
540
540
h_cb_pos .append (len (h ))
541
541
h .append (Size .from_any (self ._colorbar_size , sz ))
@@ -552,20 +552,19 @@ def _update_locators(self):
552
552
sz = Size .AxesY (self .axes_all [0 ],
553
553
aspect = "axes" , ref_ax = self .axes_all [0 ])
554
554
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 ))) :
558
558
v_cb_pos .append (len (v ))
559
559
v .append (Size .from_any (self ._colorbar_size , sz ))
560
560
v .append (Size .from_any (self ._colorbar_pad , sz ))
561
561
562
562
v_ax_pos .append (len (v ))
563
563
v .append (sz )
564
564
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 ))):
569
568
v .append (Size .from_any (self ._colorbar_pad , sz ))
570
569
v_cb_pos .append (len (v ))
571
570
v .append (Size .from_any (self ._colorbar_size , sz ))
@@ -576,51 +575,49 @@ def _update_locators(self):
576
575
ny = v_ax_pos [self ._nrows - 1 - row ])
577
576
self .axes_all [i ].set_axes_locator (locator )
578
577
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" ):
581
580
locator = self ._divider .new_locator (
582
581
nx = h_cb_pos [col ], ny = v_ax_pos [self ._nrows - 1 - row ])
583
582
584
- elif self . _colorbar_location in ("top" , "bottom" ):
583
+ elif cb_location in ("top" , "bottom" ):
585
584
locator = self ._divider .new_locator (
586
585
nx = h_ax_pos [col ], ny = v_cb_pos [self ._nrows - 1 - row ])
587
586
588
587
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 ):
593
591
locator = self ._divider .new_locator (
594
592
nx = h_cb_pos [0 ], ny = v_ax_pos [self ._nrows - 1 - row ])
595
593
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 ):
599
596
locator = self ._divider .new_locator (nx = h_ax_pos [col ],
600
597
ny = v_cb_pos [0 ])
601
598
self .cbar_axes [col ].set_axes_locator (locator )
602
599
603
- if self . _colorbar_mode == "single" :
604
- if self . _colorbar_location == "right" :
600
+ if cb_mode == "single" :
601
+ if cb_location == "right" :
605
602
sz = self ._nrows * Size .AxesX (self .axes_llc )
606
603
h .append (Size .from_any (self ._colorbar_pad , sz ))
607
604
h .append (Size .from_any (self ._colorbar_size , sz ))
608
605
locator = self ._divider .new_locator (nx = - 2 , ny = 0 , ny1 = - 1 )
609
- elif self . _colorbar_location == "top" :
606
+ elif cb_location == "top" :
610
607
sz = self ._ncols * Size .AxesY (self .axes_llc )
611
608
v .append (Size .from_any (self ._colorbar_pad , sz ))
612
609
v .append (Size .from_any (self ._colorbar_size , sz ))
613
610
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" ):
615
612
for i in range (self .ngrids ):
616
613
self .cbar_axes [i ].set_visible (False )
617
614
self .cbar_axes [0 ].set_axes_locator (locator )
618
615
self .cbar_axes [0 ].set_visible (True )
619
- elif self . _colorbar_mode == "each" :
616
+ elif cb_mode == "each" :
620
617
for i in range (self .ngrids ):
621
618
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" ):
624
621
count = self ._nrows
625
622
else :
626
623
count = self ._ncols
0 commit comments