python - 如何在python中堆叠seaborn pairgrids
问题描述
我正在制作一个将多个因变量与一个自变量进行比较的pairgrid。我有情节,这正是我想要的方式,除了一件事:我不希望情节排在一条很长的线上。
这是我的代码:
g = sns.PairGrid(df, y_vars=["W%"], x_vars=["PPG", "FG%", "3FG%", "FT%", 'APG', 'TOPG', 'RPG'], height=4)
g.map(sns.regplot, color=".3")
plt.ylim(0, 1)
这就是输出。我真的很想以某种方式堆叠它们,第二行也包含 y 轴和刻度。我显然可以用不同的变量运行另一个pairplot,但我希望它们都在同一个轴上。我不在乎它们是如何堆叠的,2x2x2x1、3x3x2、4x3,任何东西都可以。我只是想弄清楚该怎么做。我打算制作一个子图,但 sns.PairGrid() 没有 ax 参数。谢谢!
解决方案
使用col_wrap
和height
参数来sns.FacetGrid
。
来自 seaborn 教程https://seaborn.pydata.org/tutorial/axis_grids.html
attend = sns.load_dataset("attention").query("subject <= 12")
g = sns.FacetGrid(attend, col="subject", col_wrap=4, height=2, ylim=(0, 10))
g.map(sns.pointplot, "solutions", "score", order=[1, 2, 3], color=".3", ci=None);
推荐阅读
- python-3.x - 在 tkinter 画布中鼠标指针之后出现在画布对象中的问题
- javascript - 使用角度js问题加载日期年日下拉
- react-query - 我的 useQuery 钩子每次调用时都会重新获取。我认为应该交回缓存?
- r - 在 genlight 对象中导入记录的基因型表
- android - 带有 FragmentContainerView 的未知属性类警告
- sql-server - GETDATE() 输出中的最后一个 .mmm 是什么
- email - Microsoft Graph 发送电子邮件错误“访问被拒绝”
- c - getrlimit -1 返回值
- html - 如何防止兄弟元素堆叠?
- json - 如果不存在则创建表并插入行,否则只需插入