figure.samplesize_auc_extent_direction.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:microbiomeHD 作者: cduvallet 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号