def draw_legend(data, da, lyr):
"""
Draw a rectangle in the box
Parameters
----------
data : dataframe
da : DrawingArea
lyr : layer
Returns
-------
out : DrawingArea
"""
data['size'] *= SIZE_FACTOR
# box
facecolor = to_rgba(data['fill'], data['alpha'])
if facecolor is None:
facecolor = 'none'
kwargs = dict(
linestyle=data['linetype'],
linewidth=data['size'])
box = Rectangle((da.width*.125, da.height*.25),
width=da.width*.75,
height=da.height*.5,
facecolor=facecolor,
edgecolor=data['color'],
capstyle='projecting',
antialiased=False,
**kwargs)
da.add_artist(box)
kwargs['solid_capstyle'] = 'butt'
kwargs['color'] = data['color']
# middle strike through
strike = mlines.Line2D([da.width*.125, da.width*.875],
[da.height*.5, da.height*.5],
**kwargs)
da.add_artist(strike)
# whiskers
top = mlines.Line2D([da.width*.5, da.width*.5],
[da.height*.75, da.height*.9],
**kwargs)
da.add_artist(top)
bottom = mlines.Line2D([da.width*.5, da.width*.5],
[da.height*.25, da.height*.1],
**kwargs)
da.add_artist(bottom)
return da
评论列表
文章目录