我想在一月开始剧情,即使数据收集在3月开始2021,为了显示每年的绘图顶部彼此,并能够在视觉上比较相同月份的不同年份。
我尝试了set_xlim的以下用法,但没有成功。
只需将order参数传递给saeborn.violinplot:
fig, ax = plt.subplots(figsize=(24,10))
fontsize=18
plt.rc('xtick', labelsize=fontsize)
plt.rc('ytick', labelsize=fontsize)
plt.rcParams['font.size']=24
sns.violinplot(x = weather21_2h.index.month,
y = weather21_2h['T out_x'],
ax=ax,
palette="GnBu",
inner = "box",
order = range(1, 13))
ax.set_title('Statistique des températures par mois 2021')
ax.set_xlabel('Mois', fontsize=24)
ax.set_ylabel('Températures (°C)')
ax.grid(True)
plt.show()
调整y的显示范围也很简单:
ax.set_ylim(0,1)