@@ -803,7 +803,7 @@ def get_title(self):
803
803
return self ._legend_title_box ._text
804
804
805
805
def get_window_extent (self , * args , ** kwargs ):
806
- 'return a extent of the legend'
806
+ 'return a extent of the the legend'
807
807
return self .legendPatch .get_window_extent (* args , ** kwargs )
808
808
809
809
def get_frame_on (self ):
@@ -993,3 +993,100 @@ def draggable(self, state=None, use_blit=False, update="loc"):
993
993
self ._draggable = None
994
994
995
995
return self ._draggable
996
+
997
+
998
+ class UniformLegend (Legend ):
999
+ def __str__ (self ):
1000
+ return "uniformLegend"
1001
+
1002
+ def __init__ (self , parent , handles , labels ,uniform_size ,
1003
+ loc = None ,
1004
+ numpoints = None , # the number of points in the legend line
1005
+ markerfirst = True , # controls ordering (left-to-right) of
1006
+ # legend marker and label
1007
+ scatterpoints = None , # number of scatter points
1008
+ scatteryoffsets = None ,
1009
+ prop = None , # properties for the legend texts
1010
+ fontsize = None , # keyword to set font size directly
1011
+
1012
+ # spacing & pad defined as a fraction of the font-size
1013
+ borderpad = None , # the whitespace inside the legend border
1014
+ labelspacing = None , # the vertical space between the legend
1015
+ # entries
1016
+ handlelength = None , # the length of the legend handles
1017
+ handleheight = None , # the height of the legend handles
1018
+ handletextpad = None , # the pad between the legend handle
1019
+ # and text
1020
+ borderaxespad = None , # the pad between the axes and legend
1021
+ # border
1022
+ columnspacing = None , # spacing between columns
1023
+
1024
+ ncol = 1 , # number of columns
1025
+ mode = None , # mode for horizontal distribution of columns.
1026
+ # None, "expand"
1027
+
1028
+ fancybox = None , # True use a fancy box, false use a rounded
1029
+ # box, none use rc
1030
+ shadow = None ,
1031
+ title = None , # set a title for the legend
1032
+
1033
+ framealpha = None , # set frame alpha
1034
+
1035
+ bbox_to_anchor = None , # bbox that the legend will be anchored.
1036
+ bbox_transform = None , # transform for the bbox
1037
+ frameon = None
1038
+ ):
1039
+ uniformHandlerMap = {
1040
+ StemContainer :
1041
+ legend_handler .HandlerUniformStem (uniform_size = uniform_size ),
1042
+ ErrorbarContainer :
1043
+ legend_handler .HandlerUniformErrorBar (uniform_size = uniform_size ),
1044
+ Line2D : legend_handler .HandlerUniformLine2D (uniform_size = uniform_size ),
1045
+ PathCollection :
1046
+ legend_handler .HandlerPathCollection (sizes = [uniform_size ]* 3 ),
1047
+ RegularPolyCollection :
1048
+ legend_handler .HandlerRegularPolyCollection (sizes = [uniform_size ]* 3 ),
1049
+ CircleCollection :
1050
+ legend_handler .HandlerCircleCollection (sizes = [uniform_size ]* 3 ),
1051
+ }
1052
+
1053
+ Legend .__init__ (self ,parent ,handles ,labels ,
1054
+ loc = loc ,
1055
+ numpoints = numpoints , # the number of points in the legend line
1056
+ markerscale = None , # the relative size of legend markers
1057
+ # vs. original
1058
+ markerfirst = markerfirst , # controls ordering (left-to-right) of
1059
+ # legend marker and label
1060
+ scatterpoints = scatterpoints , # number of scatter points
1061
+ scatteryoffsets = scatteryoffsets ,
1062
+ prop = prop , # properties for the legend texts
1063
+ fontsize = fontsize , # keyword to set font size directly
1064
+
1065
+ # spacing & pad defined as a fraction of the font-size
1066
+ borderpad = borderpad , # the whitespace inside the legend border
1067
+ labelspacing = labelspacing , # the vertical space between the legend
1068
+ # entries
1069
+ handlelength = handlelength , # the length of the legend handles
1070
+ handleheight = handleheight , # the height of the legend handles
1071
+ handletextpad = handletextpad , # the pad between the legend handle
1072
+ # and text
1073
+ borderaxespad = borderaxespad , # the pad between the axes and legend
1074
+ # border
1075
+ columnspacing = columnspacing , # spacing between columns
1076
+
1077
+ ncol = 1 , # number of columns
1078
+ mode = mode , # mode for horizontal distribution of columns.
1079
+ # None, "expand"
1080
+
1081
+ fancybox = fancybox , # True use a fancy box, false use a rounded
1082
+ # box, none use rc
1083
+ shadow = shadow ,
1084
+ title = title , # set a title for the legend
1085
+
1086
+ framealpha = framealpha , # set frame alpha
1087
+
1088
+ bbox_to_anchor = bbox_to_anchor , # bbox that the legend will be anchored.
1089
+ bbox_transform = bbox_transform , # transform for the bbox
1090
+ frameon = frameon , # draw frame
1091
+ handler_map = uniformHandlerMap ,
1092
+ )
0 commit comments