@@ -608,12 +608,9 @@ def get_extent_offsets(self, renderer):
608
608
# docstring inherited.
609
609
dpicor = renderer .points_to_pixels (1. )
610
610
pad = self .pad * dpicor
611
-
612
611
w , h , xd , yd = self ._children [0 ].get_extent (renderer )
613
-
614
- return w + 2 * pad , h + 2 * pad , \
615
- xd + pad , yd + pad , \
616
- [(0 , 0 )]
612
+ return (w + 2 * pad , h + 2 * pad , xd + pad , yd + pad ,
613
+ [(0 , 0 )])
617
614
618
615
def draw (self , renderer ):
619
616
"""
@@ -668,19 +665,13 @@ def __init__(self, width, height, xdescent=0.,
668
665
*xdescent*, *ydescent* : descent of the box in x- and y-direction.
669
666
*clip* : Whether to clip the children
670
667
"""
671
-
672
668
super ().__init__ ()
673
-
674
669
self .width = width
675
670
self .height = height
676
671
self .xdescent = xdescent
677
672
self .ydescent = ydescent
678
673
self ._clip_children = clip
679
-
680
674
self .offset_transform = mtransforms .Affine2D ()
681
- self .offset_transform .clear ()
682
- self .offset_transform .translate (0 , 0 )
683
-
684
675
self .dpi_transform = mtransforms .Affine2D ()
685
676
686
677
@property
@@ -698,16 +689,14 @@ def clip_children(self, val):
698
689
699
690
def get_transform (self ):
700
691
"""
701
- Return the :class:`~matplotlib.transforms.Transform` applied
702
- to the children
692
+ Return the `~matplotlib.transforms.Transform` applied to the children.
703
693
"""
704
694
return self .dpi_transform + self .offset_transform
705
695
706
696
def set_transform (self , t ):
707
697
"""
708
698
set_transform is ignored.
709
699
"""
710
- pass
711
700
712
701
def set_offset (self , xy ):
713
702
"""
@@ -719,7 +708,6 @@ def set_offset(self, xy):
719
708
The (x, y) coordinates of the offset in display units.
720
709
"""
721
710
self ._offset = xy
722
-
723
711
self .offset_transform .clear ()
724
712
self .offset_transform .translate (xy [0 ], xy [1 ])
725
713
self .stale = True
@@ -745,8 +733,8 @@ def get_extent(self, renderer):
745
733
"""
746
734
747
735
dpi_cor = renderer .points_to_pixels (1. )
748
- return self .width * dpi_cor , self .height * dpi_cor , \
749
- self .xdescent * dpi_cor , self .ydescent * dpi_cor
736
+ return ( self .width * dpi_cor , self .height * dpi_cor ,
737
+ self .xdescent * dpi_cor , self .ydescent * dpi_cor )
750
738
751
739
def add_artist (self , a ):
752
740
'Add any :class:`~matplotlib.artist.Artist` to the container box'
@@ -816,23 +804,14 @@ def __init__(self, s,
816
804
"""
817
805
if textprops is None :
818
806
textprops = {}
819
-
820
- if "va" not in textprops :
821
- textprops ["va" ] = "baseline"
822
-
807
+ textprops .setdefault ("va" , "baseline" )
823
808
self ._text = mtext .Text (0 , 0 , s , ** textprops )
824
-
825
809
OffsetBox .__init__ (self )
826
-
827
810
self ._children = [self ._text ]
828
-
829
811
self .offset_transform = mtransforms .Affine2D ()
830
- self .offset_transform .clear ()
831
- self .offset_transform .translate (0 , 0 )
832
812
self ._baseline_transform = mtransforms .Affine2D ()
833
813
self ._text .set_transform (self .offset_transform +
834
814
self ._baseline_transform )
835
-
836
815
self ._multilinebaseline = multilinebaseline
837
816
self ._minimumdescent = minimumdescent
838
817
@@ -881,7 +860,6 @@ def set_transform(self, t):
881
860
"""
882
861
set_transform is ignored.
883
862
"""
884
- pass
885
863
886
864
def set_offset (self , xy ):
887
865
"""
@@ -893,7 +871,6 @@ def set_offset(self, xy):
893
871
The (x, y) coordinates of the offset in display units.
894
872
"""
895
873
self ._offset = xy
896
-
897
874
self .offset_transform .clear ()
898
875
self .offset_transform .translate (xy [0 ], xy [1 ])
899
876
self .stale = True
@@ -969,16 +946,10 @@ class AuxTransformBox(OffsetBox):
969
946
def __init__ (self , aux_transform ):
970
947
self .aux_transform = aux_transform
971
948
OffsetBox .__init__ (self )
972
-
973
949
self .offset_transform = mtransforms .Affine2D ()
974
- self .offset_transform .clear ()
975
- self .offset_transform .translate (0 , 0 )
976
-
977
- # ref_offset_transform is used to make the offset_transform is
978
- # always reference to the lower-left corner of the bbox of its
979
- # children.
950
+ # ref_offset_transform makes offset_transform always relative to the
951
+ # lower-left corner of the bbox of its children.
980
952
self .ref_offset_transform = mtransforms .Affine2D ()
981
- self .ref_offset_transform .clear ()
982
953
983
954
def add_artist (self , a ):
984
955
'Add any :class:`~matplotlib.artist.Artist` to the container box'
@@ -991,15 +962,14 @@ def get_transform(self):
991
962
Return the :class:`~matplotlib.transforms.Transform` applied
992
963
to the children
993
964
"""
994
- return self .aux_transform + \
995
- self . ref_offset_transform + \
996
- self .offset_transform
965
+ return ( self .aux_transform
966
+ + self . ref_offset_transform
967
+ + self .offset_transform )
997
968
998
969
def set_transform (self , t ):
999
970
"""
1000
971
set_transform is ignored.
1001
972
"""
1002
- pass
1003
973
1004
974
def set_offset (self , xy ):
1005
975
"""
@@ -1011,7 +981,6 @@ def set_offset(self, xy):
1011
981
The (x, y) coordinates of the offset in display units.
1012
982
"""
1013
983
self ._offset = xy
1014
-
1015
984
self .offset_transform .clear ()
1016
985
self .offset_transform .translate (xy [0 ], xy [1 ])
1017
986
self .stale = True
0 commit comments