@@ -113,6 +113,7 @@ def __init__(self, parent, handles, labels,
113113 ncol = 1 , # number of columns
114114 mode = None , # mode for horizontal distribution of columns. None, "expand"
115115
116+ fancybox = True ,
116117 shadow = None ,
117118 ):
118119 """
@@ -130,6 +131,7 @@ def __init__(self, parent, handles, labels,
130131 numpoints the number of points in the legend line
131132 prop the font property
132133 markerscale the relative size of legend markers vs. original
134+ fancybox if True, draw a frame with a round fancybox.
133135 shadow if True, draw a shadow behind legend
134136 scatteryoffsets a list of yoffsets for scatter symbols in legend
135137
@@ -263,8 +265,11 @@ def __init__(self, parent, handles, labels,
263265 # The width and height of the legendPatch will be set (in the
264266 # draw()) to the length that includes the padding. Thus we set
265267 # pad=0 here.
266- self .legendPatch .set_boxstyle ("round" ,pad = 0 , #self.borderpad,
267- rounding_size = 0.2 )
268+ if fancybox == True :
269+ self .legendPatch .set_boxstyle ("round" ,pad = 0 ,
270+ rounding_size = 0.2 )
271+ else :
272+ self .legendPatch .set_boxstyle ("square" ,pad = 0 )
268273
269274 self ._set_artist_props (self .legendPatch )
270275
@@ -378,7 +383,8 @@ def _init_legend_box(self, handles, labels):
378383 labelboxes = []
379384
380385 for l in labels :
381- textbox = TextArea (l , textprops = label_prop )
386+ textbox = TextArea (l , textprops = label_prop
387+ multilinebaseline = True , minimumdescent = True )
382388 text_list .append (textbox ._text )
383389 labelboxes .append (textbox )
384390
@@ -387,8 +393,8 @@ def _init_legend_box(self, handles, labels):
387393
388394 # The approximate height and descent of text. These values are
389395 # only used for plotting the legend handle.
390- height = self ._approx_text_height () * 0.6
391- descent = 0. #height/6.
396+ height = self ._approx_text_height () * 0.7
397+ descent = 0.
392398
393399 # each handle needs to be drawn inside a box of
394400 # (x, y, w, h) = (0, -descent, width, height).
@@ -440,9 +446,9 @@ def _init_legend_box(self, handles, labels):
440446 legline ._legmarker = legline_marker
441447
442448 elif isinstance (handle , Patch ):
443- p = Rectangle (xy = (0 , - 0. * descent ),
449+ p = Rectangle (xy = (0. , 0. ),
444450 width = self .handlelength * self .fontsize ,
445- height = 0. * descent + (height - descent )* .9 ,
451+ height = (height - descent ),
446452 )
447453 p .update_from (handle )
448454 self ._set_artist_props (p )
@@ -513,19 +519,21 @@ def _init_legend_box(self, handles, labels):
513519 num_smallcol = self ._ncol - num_largecol
514520
515521 # starting index of each column and number of rows in it.
516- largecol = zip (range (0 , num_largecol * (nrows + 1 ), (nrows + 1 )),
517- [nrows + 1 ] * num_largecol )
518- smallcol = zip (range (num_largecol * (nrows + 1 ), len (handleboxes ), nrows ),
519- [nrows ] * num_smallcol )
522+ largecol = safezip (range (0 , num_largecol * (nrows + 1 ), (nrows + 1 )),
523+ [nrows + 1 ] * num_largecol )
524+ smallcol = safezip (range (num_largecol * (nrows + 1 ), len (handleboxes ), nrows ),
525+ [nrows ] * num_smallcol )
520526
521- handle_label = zip (handleboxes , labelboxes )
527+ handle_label = safezip (handleboxes , labelboxes )
522528 columnbox = []
523529 for i0 , di in largecol + smallcol :
524530 # pack handleBox and labelBox into itemBox
525531 itemBoxes = [HPacker (pad = 0 ,
526532 sep = self .handletextpad * self .fontsize ,
527533 children = [h , t ], align = "baseline" )
528534 for h , t in handle_label [i0 :i0 + di ]]
535+ # minimumdescent=False for the text of the last row of the column
536+ itemBoxes [- 1 ].get_children ()[1 ].set_minimumdescent (False )
529537
530538 # pack columnBox
531539 columnbox .append (VPacker (pad = 0 ,
0 commit comments