Remove multiple x shortcuts with Seaborn

In the screenshot below, all my x-tags overlap with each other.

g = sns.factorplot(x='Age', y='PassengerId', hue='Survived', col='Sex', kind='strip', data=train); 

I know that I can remove all shortcuts by calling g.set(xticks=[]) , but is there a way to show some Age shortcuts like 0, 20, 40, 60, 80?

enter image description here

+5
source share
1 answer

I'm not sure why there are no default sensitive ticks and values, for example, on the y axis. In any case, you can do something like the following:

 import seaborn as sns import matplotlib.pyplot as plt import matplotlib.ticker as ticker titanic = sns.load_dataset('titanic') sns.factorplot(x='age',y='fare',hue='survived',col='sex',data=titanic,kind='strip') ax = plt.gca() ax.xaxis.set_major_formatter(ticker.FormatStrFormatter('%d')) ax.xaxis.set_major_locator(ticker.MultipleLocator(base=20)) plt.show() 

Result:

enter image description here

+9
source

All Articles