def stemplot(x, y, data, order, ax, palette, marker='o', size=7):
"""
Wrapper to make one stemplot with colored dashed lines leading
to colored marker.
Parameters
----------
x, y : str
used in call to sns.stripplot() with data
data : pandas dataframe
Should have the values that are given for 'order' in the index,
or a column called 'label' with those values.
order : list
order of x values
ax : Axis object
axis handle to plot values on
palette : dict
{values in x-axis : color mapping value}
marker : str
marker value to pass to stripplot
size : int
size of marker
Returns
-------
ax
"""
if 'label' in data:
data.index = data['label']
sns.stripplot(x=x, y=y, data=data, order=order, ax=ax, palette=palette,
size=size, marker=marker)
_, stemlines, baseline = ax.stem(data.loc[order, y],
markerfmt=" ", linefmt=":")
# Remove stemplot baseline
plt.setp(baseline, visible=False)
# Change stem colors
colorslist = [palette[i] for i in order]
_ = [plt.setp(stemlines[i], 'color', colorslist[i])
for i in range(len(colorslist))]
_ = [i.set_alpha(0.75) for i in stemlines]
return ax
figure.samplesize_auc_extent_direction.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录