Home > Back-end >  set x range in seaborne violinplot by month
set x range in seaborne violinplot by month

Time:02-13

I am trying to plot temperature data recorded over the year using a seaborn violinplot.

I manage to do the following plot:

Seaborn violinplor from march to december

I would like to start the plot in January, even if the data collection starts in March for 2021, in order to display yearly plots on top of each other and be able to visually compare same months of different years.

I tried the following use of set_xlim, but it didn't work

fig, ax = plt.subplots(figsize=(24,10))
fontsize=18
ax.set_xlim(1,12)
plt.rc('xtick', labelsize=fontsize) 
plt.rc('ytick', labelsize=fontsize) 

plt.rcParams['font.size']=24

seaborn.violinplot(x = weather21_2h.index.month, y = weather21_2h['T out_x'], ax=ax, palette="GnBu",inner = "box")
plt.title('Statistique des températures par mois 2021')
plt.xlabel('Mois', fontsize=24)
plt.ylabel('Températures (°C)')

plt.grid(True)

plt.show()

Is there a way ?

CodePudding user response:

You can simply pass order parameter to enter image description here

  • Related