如何更改Seaborn中非数字x轴刻度的数量?

时间:2019-04-08 02:30:09

标签: python seaborn

我正在尝试为一个海洋图设置自定义刻度,但它只显示了一半刻度。如何增加非数字值的刻度数?

enter image description here

import pandas as pd
import numpy as np
import seaborn as sns    
df_x = pd.DataFrame({'Period': list(range(1,13)),
                           '2016': np.random.randint(low=1, high=100, size=12),
                           '2017': np.random.randint(low=1, high=100, size=12),
                           '2018': np.random.randint(low=1, high=100, size=12)}) 

df_x.set_index('Period', inplace=True)
ax = sns.lineplot(data=df_x[['2016','2017','2018']])
ax.set_xticklabels(['Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec','Jan'])

我希望完全按照列出的顺序查看刻度线。

Python 3.7.1,Jupyter Notebook

1 个答案:

答案 0 :(得分:1)

设置刻度线的数量:

ax.set_xticks(range(0,12))