可视化数据,跟踪特定SD值

问题描述 投票:0回答:1

BLUF:我想跟踪一个特定的Std Dev,例如: 1.0至1.25,通过颜色编码并制作单独的KDF或其他概率密度图。

我想要做的就是能够挑选出其他的Std Dev范围并找回我可以转向的新图表并用于预测特定Std Dev的结果。

数据:https://www.dropbox.com/s/y78pynq9onyw9iu/Data.csv?dl=0

到目前为止我所拥有的是一个看起来像霰弹枪爆炸的标准化数据:

enter image description here

用于生成它的代码:

data = pd.read_csv("Data.csv")
sns.jointplot(data.x,data.y, space=0.2, size=10, ratio=2, kind="reg");

我想在这里实现的目标看起来像我在下面标记的内容:

enter image description here

我有点知道如何使用RidgePlot类型的函数在RStudio中做到这一点,但我在Python中不知所措,即使在使用Seaborn时也是如此。任何/所有帮助表示赞赏!

data-visualization seaborn standard-deviation kernel-density
1个回答
1
投票

以下代码可能会直接指向您,您可以从那里根据需要调整绘图的外观。

tips = sns.load_dataset("tips")
g = sns.jointplot(x="total_bill", y="tip", data=tips)

top_lim = 4
bottom_lim = 2
temp = tips.loc[(tips.tip>=bottom_lim)&(tips.tip<top_lim)]
g.ax_joint.axhline(top_lim, c='k', lw=2)
g.ax_joint.axhline(bottom_lim, c='k', lw=2)

# we have to create a secondary y-axis to the joint-plot, otherwise the
# kde might be very small compared to the scale of the original y-axis
ax_joint_2 = g.ax_joint.twinx()
sns.kdeplot(temp.total_bill, shade=True, color='red', ax=ax_joint_2, legend=False)
ax_joint_2.spines['right'].set_visible(False)
ax_joint_2.spines['top'].set_visible(False)
ax_joint_2.yaxis.set_visible(False)

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.