我正在使用 seaborn
进行绘图我正在使用 seaborn.PairGrid
功能。这是创建 6 x 6 网格,其中对角线图是直方图,非对角线图是散点图。现在我想为每行图设置不同的 y 范围,并为每列图设置不同的 x 范围。我搜索了很多堆栈交换,但找不到实现这一目标的方法。 Matplot 版本是 2.0.0
和 seaborn
版本是 0.7.1
.
谢谢
最佳答案
您可以使用 Axes.set_xlim()
和 Axes.set_ylim()
seaborn 轴上的方法 PairGrid
或 FacetGrid
.轴可从 PairGrid
获得如 .axes
属性。
导入 matplotlib.pyplot 作为 plt
将 seaborn 作为 sns 导入
iris = sns.load_dataset("iris")
g = sns.PairGrid(iris)
g = g.map_diag(plt.hist, edgecolor="k")
g = g.map_offdiag(plt.scatter, s=10)
g.axes[2,0].set_ylim(-10,10)
g.axes[0,1].set_xlim(-40,10)
plt.show()
关于matplotlib - 为 seaborn PairGrid 设置不同的轴范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43383365/