def draw_group(data, panel_params, coord, ax, **params):
data = coord.transform(data, panel_params, munch=True)
data['size'] *= SIZE_FACTOR
# Each group is a polygon with a single facecolor
# with potentially an edgecolor for every edge.
ngroups = data['group'].unique().size
verts = [None] * ngroups
facecolor = [None] * ngroups
edgecolor = [None] * ngroups
linestyle = [None] * ngroups
linewidth = [None] * ngroups
# Some stats may order the data in ways that prevent
# objects from occluding other objects. We do not want
# to undo that order.
grouper = data.groupby('group', sort=False)
for i, (group, df) in enumerate(grouper):
verts[i] = tuple(zip(df['x'], df['y']))
fill = to_rgba(df['fill'].iloc[0], df['alpha'].iloc[0])
facecolor[i] = 'none' if fill is None else fill
edgecolor[i] = df['color'].iloc[0] or 'none'
linestyle[i] = df['linetype'].iloc[0]
linewidth[i] = df['size'].iloc[0]
col = PolyCollection(
verts,
facecolors=facecolor,
edgecolors=edgecolor,
linestyles=linestyle,
linewidths=linewidth,
transOffset=ax.transData,
zorder=params['zorder'])
ax.add_collection(col)
评论列表
文章目录