[英]Reduce Seaborn KDE Plot Margins
嗨,我有下面的代码,可以在关节图的边缘生成多个KDE图
h = sns.JointGrid('SECS', 'EPOCH', df)
for name, group in df.groupby("QUERY"):
sns.kdeplot(group["SECS"], ax=h.ax_marg_x, legend=False)
sns.kdeplot(group["EPOCH"], ax=h.ax_marg_y, vertical=True, legend=False)
h.ax_joint.plot(group["SECS"], group["EPOCH"], ".", ms=5)
我想知道如何限制边距,以便图形从0开始而不是从-20000开始,那里有很多死角。
您可以使用ax_joint
访问JointGrid
的主图,就像首先绘制数据一样。 如果打印h.ax_joint
的类型, h.ax_joint
可以看到它是matplotlib.axes._subplots.AxesSubplot
。 因此,您可以像通常使用matplotlib一样操纵轴的极限。
例如:
h = sns.JointGrid('SECS', 'EPOCH', df)
for name, group in df.groupby("QUERY"):
sns.kdeplot(group["SECS"], ax=h.ax_marg_x, legend=False)
sns.kdeplot(group["EPOCH"], ax=h.ax_marg_y, vertical=True, legend=False)
h.ax_joint.plot(group["SECS"], group["EPOCH"], ".", ms=5)
h.ax_joint.set_xlim(0,90000)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.