【问题标题】:How to show more details in `seaborn.kdeplot()`?如何在 `seaborn.kdeplot()` 中显示更多细节?
【发布时间】:2016-11-22 16:49:33
【问题描述】:

我在下方左侧有一个散点图,其中有很多数据点,右图是使用seaborn.kdeplot()的对应密度图。但不幸的是,由于密度的方差太大,以至于kdeplot 未能捕捉到其他低密度区域的许多细节(例如,右上角基本上没有关于密度分布的信息)。

有人有办法解决这个问题吗?

谢谢!

【问题讨论】:

  • BTW 不请自来的建议:看起来您正在使用圆形颜色图来显示 0 到 2 * pi 之间的值;确保将颜色图限制设置为包括整个范围。
  • @mwaskom 实际上我没有使用循环变量,它们恰好落入 [0, 2*pi]。不过感谢您的建议。

标签: seaborn kernel-density density-plot


【解决方案1】:

可以使用n_levels参数,即

f, axes = plt.subplots(1, 3, figsize=(15, 5), sharex=True, sharey=True)
x, y = np.random.normal(0, 1, (2, 1000))
axes[0].scatter(x, y, s=5, c=".1")
sns.kdeplot(x, y, n_levels=10, ax=axes[1])
sns.kdeplot(x, y, n_levels=30, ax=axes[2])
f.tight_layout()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多