如何解决使seaborn.PairGrid看起来像pairplot
在下面的示例中,如何使用seaborn.PairGrid()
复制由seaborn.pairplot()
创建的图?具体来说,我希望对角线分布跨越垂直轴。带有白色边框等的标记也会很棒。谢谢!
import seaborn as sns
import matplotlib.pyplot as plt
iris = sns.load_dataset('iris')
# pairplot() example
g = sns.pairplot(iris,kind='scatter',diag_kind='kde')
plt.show()
# PairGrid() example
g = sns.PairGrid(iris)
g.map_diag(sns.kdeplot)
g.map_offdiag(plt.scatter)
plt.show()
解决方法
这是quite simple要实现的。您的剧情与pairplot
所做的主要区别是:
- 使用
diag_sharey
的{{1}}参数 - 使用
PairGrid
代替sns.scatterplot
有了,我们有:
plt.scatter
,
要更改视觉样式:
import seaborn as sns
import matplotlib.pyplot as plt
iris = sns.load_dataset('iris')
g = sns.PairGrid(iris)
g.map_diag(sns.kdeplot,shade=True)
g.map_offdiag(plt.scatter,edgecolor="w")
plt.show()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。