python - 减少 Seaborn KDE 绘图边距
问题描述
嗨,我有下面的代码,可以在联合图的边缘生成多个 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 开始,那里有很多死区。
解决方案
您可以像首先绘制数据一样访问 a JointGrid
using的主图。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)
推荐阅读
- axios - next.js Api 路由给我警告,例如 / API 已解决,但未发送 /api/*** 的响应,这可能会导致请求停止
- javascript - 未捕获的 SyntaxError:标识符“x”已被声明
- c# - 从 Azure Active Directory 获取最近添加/更新的用户
- javascript - 在 javascript 中处理大型 Json 字符串
- python - 从excel复制列
- vba - 公共子系统上的 MS Access Openform
- visual-sourcesafe - 在 VSS 6.0 中比较两个文件时文本不可见
- aws-lambda - 调用 AWS Lambda 的代理背后的 WSO2 Api 网关
- c# - C# 在自身内部启动线程
- apache - 带有哈希“#”字符的 apache 2.4 proxypass url