Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 748
dsaxton Avatar asked Sep 12 '15 19:09

dsaxton


People also ask

How do I remove a tick label from Seaborn?

To remove X or Y labels from a Seaborn heatmap, we can use yticklabel=False.

How do I reduce the number of ticks in Seaborn?

To decrease the density of x-ticks in Seaborn, we can use set_visible=False for odd positions.


2 Answers

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

enter image description here

like image 170
mwaskom Avatar answered Sep 20 '22 01:09

mwaskom


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

like image 44
Alexander Avatar answered Sep 23 '22 01:09

Alexander