【问题标题】:Seaborn jointplot joint density level / color scale adjustmentSeaborn jointplot 联合密度等级/色标调整
【发布时间】:2016-03-16 11:30:52
【问题描述】:

我可以向你展示比我可以解释的更好:

我使用 seaborn 绘制了两个时间序列的联合图,但我想更改密度的比例,以便可以看到更多的联合分布。

结果如下:

g = sns.jointplot(x1, x2, kind="kde", ratio=5, size=7, space=0)

图 1:seaborn 两个时间序列的联合图:

但是当我将观察结果叠加在联合图之上时,我可以看到在彩色区域之外有很多观察结果。我使用 g.plot_joint 来叠加散点图:

g.plot_joint(plt.scatter, c="k", s=10, linewidth=1, marker="+")

图2:叠加散点图的联合图

有没有办法以某种方式调整联合图以显示更大的分布区域?即使在联合分布不太密集的区域,我也希望看到一些着色。

【问题讨论】:

    标签: python matplotlib seaborn


    【解决方案1】:

    只需使用n_levels 关键字。默认值为n_levels=10。它没有很好的记录,但我发现它在源代码中挖掘。

    g = sns.jointplot(x1, x2, kind="kde", ratio=5, size=7, space=0, n_levels=100)
    

    【讨论】:

    • 太好了,谢谢罗伯!我试图从文档中找到类似的东西,但找不到。
    • 它仍然对我有用。当然它只在kind='kde'时有效,因为关键字被传递给底层的kdeplot。
    猜你喜欢
    • 2017-06-11
    • 2018-12-15
    • 2015-10-02
    • 2019-09-14
    • 2019-10-28
    • 2017-05-18
    • 1970-01-01
    • 2020-11-16
    • 1970-01-01
    相关资源
    最近更新 更多