Sad Vaseb
Sad Vaseb

Reputation: 339

Adding axis to all boxes in Seaborn pairplots

I have a pairplot in Python. I like to add x-axis and y-axis ticks (i.e, numbers) to all boxes. So, the ticks and their labels at the bottom and left side of pairplot will repeat for each box. See the below pictures.

Thanks in advance!

What I have

enter image description here

what I want to have

enter image description here

Upvotes: 1

Views: 1526

Answers (1)

r-beginners
r-beginners

Reputation: 35205

You can set ax.tick_params() and adjust the subplot spacing.

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

Upvotes: 4

Related Questions