如何更改设置的箱形图子图上的xticks,以使名称显示为“ March”而不是3.0,即使有几个月没有数据,也要包含全年?
我想用一整月的时间作为整个一年的xticks,但是我的数据在完成程度上有所不同,即有些年份有7/12个月等。
%matplotlib inline
import matplotlib.pyplot as plt
df['month'] = df.index.month
fig, axes = plt.subplots(3,3, figsize=(15,15)) # create figure and axes
data = df.loc[:, ['scat450', 'scat550', 'scat700','bscat450','bscat550','bscat700', 'p_int', 'T_int', 'RH_int','month']]
varlist = ['scat450', 'scat550', 'scat700','bscat450','bscat550','bscat700', 'p_int', 'T_int', 'RH_int','month']
y_labels = ['Mm-1','Mm-1','Mm-1','Mm-1','Mm-1','Mm-1','mbar','celsius','%']
#Months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
df_12hourly = df[varlist].resample('12H').median()
for i,el in enumerate(list(df_12hourly.columns.values)[:-1]):
a = df_12hourly.boxplot(el, by="month", showfliers=False, ax=axes.flatten()[i])
#a.set_xticklabels(df.month, rotation=45 )
#a.xaxis.set_major_formatter(mdates.DateFormatter("%b"))
a.set_ylabel(y_labels[i])
a.set_xlim(0,13)
fig.suptitle(str(year), fontsize=16)