dsaxton
dsaxton

Reputation: 1015

Control tick labels in Python seaborn package

I have a scatter plot matrix generated using the seaborn package and I'd like to remove all the tick mark labels as these are just messying up the graph (either that or just remove those on the x-axis), but I'm not sure how to do it and have had no success doing Google searches. Any suggestions?

import seaborn as sns
sns.pairplot(wheat[['area_planted',
    'area_harvested',
    'production',
    'yield']])
plt.show()

enter image description here

Upvotes: 16

Views: 74756

Answers (3)

hola
hola

Reputation: 612

Probably using the following is more appropriate

import seaborn as sns


iris = sns.load_dataset("iris")
g = sns.pairplot(iris)
g.set(xticks=[])

Upvotes: 3

mwaskom
mwaskom

Reputation: 49022

import seaborn as sns
iris = sns.load_dataset("iris")
g = sns.pairplot(iris)
g.set(xticklabels=[])

enter image description here

Upvotes: 38

Alexander
Alexander

Reputation: 109696

You can use a list comprehension to loop through all columns and turn off visibility of the xaxis.

df = pd.DataFrame(np.random.randn(1000, 2)) * 1e6
sns.pairplot(df)

enter image description here

plot = sns.pairplot(df)
[plot.axes[len(df.columns) - 1][col].xaxis.set_visible(False) 
 for col in range(len(df.columns))]
plt.show()

enter image description here

You could also rescale your data to something more readable:

df /= 1e6
sns.pairplot(df)

enter image description here

Upvotes: 4

Related Questions