将轴添加到Seaborn PairPlot中的所有长方体

2024-10-02 22:31:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个Python的pairplot。我喜欢将x轴和y轴记号(即数字)添加到所有框中。因此,pairplot底部和左侧的记号及其标签将对每个框重复。请看下面的图片

提前谢谢

我所拥有的

enter image description here

我想要什么

enter image description here


Tags: 图片数字标签记号pairplot
1条回答
网友
1楼 · 发布于 2024-10-02 22:31:15

您可以设置ax.tick_params()并调整子地块间距

import matplotlib.pyplot as plt
import seaborn as sns

penguins = sns.load_dataset("penguins")

pp = sns.pairplot(
    penguins,
    x_vars=["bill_length_mm", "bill_depth_mm", "flipper_length_mm"],
    y_vars=["bill_length_mm", "bill_depth_mm"],
)
for ax in pp.axes.flat:
    ax.tick_params(axis='both', labelleft=True, labelbottom=True)
    
plt.subplots_adjust(wspace=0.3, hspace=0.3)

plt.show()

enter image description here

相关问题 更多 >