26
26
unicode_literals )
27
27
28
28
import six
29
- from six .moves import xrange
30
29
31
30
import logging
32
31
import warnings
@@ -907,15 +906,13 @@ def _init_legend_box(self, handles, labels, markerfirst=True):
907
906
908
907
text_list = [] # the list of text instances
909
908
handle_list = [] # the list of text instances
909
+ handles_and_labels = []
910
910
911
911
label_prop = dict (verticalalignment = 'baseline' ,
912
912
horizontalalignment = 'left' ,
913
913
fontproperties = self .prop ,
914
914
)
915
915
916
- labelboxes = []
917
- handleboxes = []
918
-
919
916
# The approximate height and descent of text. These values are
920
917
# only used for plotting the legend handle.
921
918
descent = 0.35 * self ._approx_text_height () * (self .handleheight - 0.7 )
@@ -948,26 +945,23 @@ def _init_legend_box(self, handles, labels, markerfirst=True):
948
945
textbox = TextArea (lab , textprops = label_prop ,
949
946
multilinebaseline = True ,
950
947
minimumdescent = True )
951
- text_list .append (textbox ._text )
952
-
953
- labelboxes .append (textbox )
954
-
955
948
handlebox = DrawingArea (width = self .handlelength * fontsize ,
956
949
height = height ,
957
950
xdescent = 0. , ydescent = descent )
958
- handleboxes .append (handlebox )
959
951
952
+ text_list .append (textbox ._text )
960
953
# Create the artist for the legend which represents the
961
954
# original artist/handle.
962
955
handle_list .append (handler .legend_artist (self , orig_handle ,
963
956
fontsize , handlebox ))
957
+ handles_and_labels .append ((handlebox , textbox ))
964
958
965
- if handleboxes :
959
+ if handles_and_labels :
966
960
# We calculate number of rows in each column. The first
967
961
# (num_largecol) columns will have (nrows+1) rows, and remaining
968
962
# (num_smallcol) columns will have (nrows) rows.
969
- ncol = min (self ._ncol , len (handleboxes ))
970
- nrows , num_largecol = divmod (len (handleboxes ), ncol )
963
+ ncol = min (self ._ncol , len (handles_and_labels ))
964
+ nrows , num_largecol = divmod (len (handles_and_labels ), ncol )
971
965
num_smallcol = ncol - num_largecol
972
966
# starting index of each column and number of rows in it.
973
967
rows_per_col = [nrows + 1 ] * num_largecol + [nrows ] * num_smallcol
@@ -976,15 +970,14 @@ def _init_legend_box(self, handles, labels, markerfirst=True):
976
970
else :
977
971
cols = []
978
972
979
- handle_label = list (zip (handleboxes , labelboxes ))
980
973
columnbox = []
981
974
for i0 , di in cols :
982
975
# pack handleBox and labelBox into itemBox
983
976
itemBoxes = [HPacker (pad = 0 ,
984
977
sep = self .handletextpad * fontsize ,
985
978
children = [h , t ] if markerfirst else [t , h ],
986
979
align = "baseline" )
987
- for h , t in handle_label [i0 :i0 + di ]]
980
+ for h , t in handles_and_labels [i0 :i0 + di ]]
988
981
# minimumdescent=False for the text of the last row of the column
989
982
if markerfirst :
990
983
itemBoxes [- 1 ].get_children ()[1 ].set_minimumdescent (False )
@@ -1207,7 +1200,7 @@ def _get_anchored_bbox(self, loc, bbox, parentbbox, renderer):
1207
1200
"""
1208
1201
assert loc in range (1 , 11 ) # called only internally
1209
1202
1210
- BEST , UR , UL , LL , LR , R , CL , CR , LC , UC , C = list ( xrange ( 11 ) )
1203
+ BEST , UR , UL , LL , LR , R , CL , CR , LC , UC , C = range ( 11 )
1211
1204
1212
1205
anchor_coefs = {UR : "NE" ,
1213
1206
UL : "NW" ,
0 commit comments