Seaborn jointplot改变了两个边缘图的带宽

2024-05-05 00:47:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在绘制一个双变量密度图,每个变量都有边际图。我发现结果太平滑了,所以我试图减少带宽。但是,当我尝试使用bw参数时,它只改变了x边缘图。在

有没有一种简单的方法来改变x和y边缘图的带宽?在

g=sns.jointplot(x=xvar, y=yvar, kind='kde',marginal_kws=dict(bw=0.8),bw=0.8)

bivariate kde plot

编辑以包含最小、完整且可验证的示例:

^{pr2}$

Tags: 方法参数绘制边缘密度bwsns边际
1条回答
网友
1楼 · 发布于 2024-05-05 00:47:04

如果您想要更多的控制,您必须直接使用JointGrid

iris = sns.load_dataset("iris")
g = sns.JointGrid(x="sepal_width", y="petal_length", data=iris, space=0)
g = g.plot_joint(sns.kdeplot, cmap="Blues_d")
sns.kdeplot(iris["sepal_width"], color="b", shade=True, bw=0.1, ax=g.ax_marg_x)
sns.kdeplot(iris["petal_length"], color="r", shade=True, bw=0.01, vertical=True, ax=g.ax_marg_y)

enter image description here

相关问题 更多 >