【问题标题】:How to set all edgecolor to none in Seaborn / Matplotlib?如何在 Seaborn / Matplotlib 中将所有边缘颜色设置为无?
【发布时间】:2018-02-15 15:38:07
【问题描述】:

我将edgecolor=none 传递给绘图以使图形的边缘消失。 整个代码如下所示:

sns.countplot(x="Survived", data=titanic_df, ax=ax1, palette='Pastel1', edgecolor='none')

但是,我每次在可视化图表时都必须这样做,这很烦人。如何将 seaborn / matplolib 设置为默认 edgecolor 为无???

谢谢!

【问题讨论】:

    标签: python matplotlib data-visualization seaborn data-science


    【解决方案1】:

    您似乎使用的是旧版本的 matplotlib。 Matplotlib 2.0 版默认没有条边。因此,一个简单的解决方案可能是将 matplotlib 和 seaborn 更新到最新版本。

    基本上你问的是这个问题的反面No outlines on bins of Matplotlib histograms or Seaborn distplots

    使用任一

    plt.rcParams['patch.linewidth'] = 0
    plt.rcParams['patch.edgecolor'] = 'none'
    

    在脚本的开头(但可能在导入 seaborn 之后,如果使用的是旧版本的 seaborn)应该会给出预期的结果,即像条形图块上没有边缘。

    如果边缘因某种其他机制而消失并且您实际上使用的是 matplotlib 2.0,则可能需要设置

    plt.rcParams["patch.force_edgecolor"] = False
    

    此外。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-16
      • 2019-03-08
      • 1970-01-01
      • 2017-09-25
      • 2013-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多