2016-08-06 59 views
5

下のスクリーンショットでは、すべてのxラベルが互いに重なっています。Seabornでいくつかのxラベルを削除する

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

私はg.set(xticks=[])を呼び出すことにより、すべてのラベルを削除することができますが、ちょうど年齢ラベルの一部を表示する方法があり、80、60、40、20、0のようなことを知っていますか?

enter image description here

答えて

9

私はy軸上にあるように賢明なデフォルトティックと値が存在しない理由を確認していません。

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() 

結果:

enter image description here

いずれにせよ、あなたは、次のような何かを行うことができます
関連する問題