@@ -494,8 +494,8 @@ def __init__(self, fig,
494
494
share_all False [ True | False ]
495
495
aspect True [ True | False ]
496
496
label_mode "L" [ "L" | "1" | "all" ]
497
- cbar_mode None [ "each" | "single" ]
498
- cbar_location "right" [ "right" | "top" ]
497
+ cbar_mode None [ "each" | "single" | "edge" ]
498
+ cbar_location "right" [ "left" | " right" | "bottom " | "top" ]
499
499
cbar_pad None
500
500
cbar_size "5%"
501
501
cbar_set_cax True [ True | False ]
@@ -631,42 +631,78 @@ def __init__(self, fig,
631
631
def _update_locators (self ):
632
632
633
633
h = []
634
+ v = []
634
635
635
636
h_ax_pos = []
636
637
h_cb_pos = []
637
- for ax in self ._column_refax :
638
- if h : h .append (self ._horiz_pad_size ) #Size.Fixed(self._axes_pad))
638
+ if self ._colorbar_mode == "single" and self ._colorbar_location in ('left' , 'bottom' ):
639
+ if self ._colorbar_location == "left" :
640
+ #sz = Size.Fraction(Size.AxesX(self.axes_llc), self._nrows)
641
+ sz = Size .Fraction (self ._nrows , Size .AxesX (self .axes_llc ))
642
+ h .append (Size .from_any (self ._colorbar_size , sz ))
643
+ h .append (Size .from_any (self ._colorbar_pad , sz ))
644
+ locator = self ._divider .new_locator (nx = 0 , ny = 0 , ny1 = - 1 )
645
+ elif self ._colorbar_location == "bottom" :
646
+ #sz = Size.Fraction(Size.AxesY(self.axes_llc), self._ncols)
647
+ sz = Size .Fraction (self ._ncols , Size .AxesY (self .axes_llc ))
648
+ v .append (Size .from_any (self ._colorbar_size , sz ))
649
+ v .append (Size .from_any (self ._colorbar_pad , sz ))
650
+ locator = self ._divider .new_locator (nx = 0 , nx1 = - 1 , ny = 0 )
651
+ for i in range (self .ngrids ):
652
+ self .cbar_axes [i ].set_visible (False )
653
+ self .cbar_axes [0 ].set_axes_locator (locator )
654
+ self .cbar_axes [0 ].set_visible (True )
639
655
640
- h_ax_pos .append (len (h ))
656
+ for col ,ax in enumerate (self ._column_refax ):
657
+ if h : h .append (self ._horiz_pad_size ) #Size.Fixed(self._axes_pad))
641
658
642
659
if ax :
643
660
sz = Size .AxesX (ax )
644
661
else :
645
662
sz = Size .AxesX (self .axes_llc )
663
+
664
+ if (self ._colorbar_mode == "each" or
665
+ (self ._colorbar_mode == 'edge' and
666
+ col == 0 )) and self ._colorbar_location == "left" :
667
+ h_cb_pos .append (len (h ))
668
+ h .append (Size .from_any (self ._colorbar_size , sz ))
669
+ h .append (Size .from_any (self ._colorbar_pad , sz ))
670
+
671
+ h_ax_pos .append (len (h ))
672
+
646
673
h .append (sz )
647
674
648
- if self ._colorbar_mode == "each" and self ._colorbar_location == "right" :
675
+ if (self ._colorbar_mode == "each" or
676
+ (self ._colorbar_mode == 'edge' and
677
+ col == self ._ncols - 1 )) and self ._colorbar_location == "right" :
649
678
h .append (Size .from_any (self ._colorbar_pad , sz ))
650
679
h_cb_pos .append (len (h ))
651
680
h .append (Size .from_any (self ._colorbar_size , sz ))
652
681
653
682
654
- v = []
655
-
656
683
v_ax_pos = []
657
684
v_cb_pos = []
658
- for ax in self ._row_refax [::- 1 ]:
685
+ for row , ax in enumerate ( self ._row_refax [::- 1 ]) :
659
686
if v : v .append (self ._horiz_pad_size ) #Size.Fixed(self._axes_pad))
660
687
661
- v_ax_pos .append (len (v ))
662
688
if ax :
663
689
sz = Size .AxesY (ax )
664
690
else :
665
691
sz = Size .AxesY (self .axes_llc )
666
- v .append (sz )
667
692
693
+ if (self ._colorbar_mode == "each" or
694
+ (self ._colorbar_mode == 'edge' and
695
+ row == 0 )) and self ._colorbar_location == "bottom" :
696
+ v_cb_pos .append (len (v ))
697
+ v .append (Size .from_any (self ._colorbar_size , sz ))
698
+ v .append (Size .from_any (self ._colorbar_pad , sz ))
668
699
669
- if self ._colorbar_mode == "each" and self ._colorbar_location == "top" :
700
+ v_ax_pos .append (len (v ))
701
+ v .append (sz )
702
+
703
+ if (self ._colorbar_mode == "each" or
704
+ (self ._colorbar_mode == 'edge' and
705
+ row == self ._nrows - 1 )) and self ._colorbar_location == "top" :
670
706
v .append (Size .from_any (self ._colorbar_pad , sz ))
671
707
v_cb_pos .append (len (v ))
672
708
v .append (Size .from_any (self ._colorbar_size , sz ))
@@ -680,13 +716,24 @@ def _update_locators(self):
680
716
self .axes_all [i ].set_axes_locator (locator )
681
717
682
718
if self ._colorbar_mode == "each" :
683
- if self ._colorbar_location == "right" :
719
+ if self ._colorbar_location in ( "right" , "left" ) :
684
720
locator = self ._divider .new_locator (nx = h_cb_pos [col ],
685
721
ny = v_ax_pos [self ._nrows - 1 - row ])
686
- elif self ._colorbar_location == "top" :
722
+ elif self ._colorbar_location in ( "top" , "bottom" ) :
687
723
locator = self ._divider .new_locator (nx = h_ax_pos [col ],
688
724
ny = v_cb_pos [self ._nrows - 1 - row ])
689
725
self .cbar_axes [i ].set_axes_locator (locator )
726
+ elif self ._colorbar_mode == 'edge' :
727
+ if ((self ._colorbar_location == 'left' and col == 0 ) or
728
+ (self ._colorbar_location == 'right' and col == self ._ncols - 1 )):
729
+ locator = self ._divider .new_locator (nx = h_cb_pos [0 ],
730
+ ny = v_ax_pos [self ._nrows - 1 - row ])
731
+ self .cbar_axes [row ].set_axes_locator (locator )
732
+ elif ((self ._colorbar_location == 'bottom' and row == self ._nrows - 1 ) or
733
+ (self ._colorbar_location == 'top' and row == 0 )):
734
+ locator = self ._divider .new_locator (nx = h_ax_pos [col ],
735
+ ny = v_cb_pos [0 ])
736
+ self .cbar_axes [col ].set_axes_locator (locator )
690
737
691
738
692
739
if self ._colorbar_mode == "single" :
@@ -702,13 +749,23 @@ def _update_locators(self):
702
749
v .append (Size .from_any (self ._colorbar_pad , sz ))
703
750
v .append (Size .from_any (self ._colorbar_size , sz ))
704
751
locator = self ._divider .new_locator (nx = 0 , nx1 = - 1 , ny = - 2 )
705
- for i in range (self .ngrids ):
706
- self .cbar_axes [i ].set_visible (False )
707
- self .cbar_axes [0 ].set_axes_locator (locator )
708
- self .cbar_axes [0 ].set_visible (True )
752
+ if self ._colorbar_location in ("right" , "top" ):
753
+ for i in ran
A165
ge (self .ngrids ):
754
+ self .cbar_axes [i ].set_visible (False )
755
+ self .cbar_axes [0 ].set_axes_locator (locator )
756
+ self .cbar_axes [0 ].set_visible (True )
709
757
elif self ._colorbar_mode == "each" :
710
758
for i in range (self .ngrids ):
711
759
self .cbar_axes [i ].set_visible (True )
760
+ elif self ._colorbar_mode == "edge" :
761
+ if self ._colorbar_location in ('right' , 'left' ):
762
+ count = self ._nrows
763
+ else :
764
+ count = self ._ncols
765
+ for i in range (count ):
766
+ self .cbar_axes [i ].set_visible (True )
767
+ for j in range (i + 1 , self .ngrids ):
768
+ self .cbar_axes [j ].set_visible (False )
712
769
else :
713
770
for i in range (self .ngrids ):
714
771
self .cbar_axes [i ].set_visible (False )
0 commit comments