【问题标题】:Edgecolor not appearing on Seaborn stripplot边缘颜色没有出现在 Seaborn 的带状图上
【发布时间】:2021-10-07 08:58:14
【问题描述】:

按照 Seaborn API 网站上的示例,我似乎无法让边缘颜色出现

这是我正在使用的

import seaborn as sns
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.boxplot(x="day", y="total_bill", data=tips)
ax = sns.stripplot(x="day", y="total_bill", data=tips, size=4, jitter=True, edgecolor="gray")

但这就是正在绘制的内容。我错过了什么吗?我在 Python 3 中使用 Seaborn .6 和 Matplotlib 1.4.3

Seaborn Boxplot API

【问题讨论】:

    标签: python matplotlib seaborn


    【解决方案1】:
    • 必须将大于 0 的 linewidth 添加到 seaborn.stripplot,以显示边缘颜色 (ec)。
      • lw 不会导致错误,但如果 lw 用于 linewidth,则不会显示边缘颜色。
    • python 3.8.11pandas 1.3.3matplotlib 3.4.3seaborn 0.11.2中测试
    import seaborn as sns
    
    # load dataframe
    tips = sns.load_dataset("tips")
    
    ax = sns.boxplot(x="day", y="total_bill", data=tips)
    
    # add stripplot with linewidth=1
    sns.stripplot(x="day", y="total_bill", data=tips, size=4, jitter=True,
                  edgecolor="gray", ax=ax, linewidth=1)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-17
      • 1970-01-01
      • 2018-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-16
      • 1970-01-01
      相关资源
      最近更新 更多