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