I would like to change the start and end month on my histogram so I can see the bars followed: November, December, January, February an March.
The idea is start the hist.plot from month 7 and end in 6 (for example).
My code is something like this:
d = {'days': [7 , 33 , 50 , 51 , 53 , 71 , 84 , 85 ,324 ,343 ,344 ,345 ,357],
'month': [ 1, 2, 2, 2, 2, 3, 3, 3,11,12,12,12,12]}
df_example = pd.DataFrame(data=d)
Then the function I'm using:
def histogram_ssw(variable1, variable2, title):
fig, ax = plt.subplots(1,1,figsize=(20,7))
fig.suptitle('Histogram' + title,fontsize=22,weight='bold')
mean = variable2.mean()
std = variable2.std()
count1,bins1,ignored1 = ax.hist(variable1[~np.isnan(variable1)],bins=25,density='True')#,label='empirica')
ax.set_title('whatever');
ax.set_xlabel('days')
ax.set_ylabel('frec')
ylim0 = ax.get_ylim()
x1 = np.linspace(bins1.min(),bins1.max(),100)
N = nor(np.nanmean(variable2),variable2.std(),x1)
x_formatter = dates.DateFormatter('%m-%d')
#ax.xaxis.set_major_formatter(x_formatter)
ax.xaxis.set_major_locator(dates.DayLocator(interval=1))
plt.gcf().autofmt_xdate(rotation=60)
#ax.set_xticklabels(df_niño3EP["M-D"].tolist(),rotation = 60)
#ax.tick_params(axis="both", direction="in", pad=15)
#ax.get_xticks(df_niño3EP["M-D"])
#mmax = np.max(ylim0[1])
#ax.set_ylim([0,mmax])
ax.grid()
plt.show()
We execute the function for my df:
histogram_ex(df_example['months'], df_ejemplo['days'], 'pff')
So it returns:
As you can see they're separated and I want it centered...