Data
df = pd.DataFrame({'Countries': ['Australia', 'India', 'UAE', 'UK'],
'3/1/20': [ 27, 3, 21, 36],
'3/2/20': [ 30, 5, 21, 40],
'3/3/20': [ 39, 5, 27, 51],
'3/4/20': [ 52, 28, 27, 86],
},
index = [0, 1, 2, 3])
df2=df.set_index('Countries').T.unstack().reset_index()
df2#.plot(kind='bar')
df2.columns=['Countries','Date','Count']
df2['Date']=pd.to_datetime(df2['Date'])
df2.dtypes
df
I tried getting mdates formatted and ticks after the state interval. line graph works but not bar graph
my code
loc = DayLocator(interval=2)
fig, ax = plt.subplots()
#ax.bar(df2.index.day,df2['Count'])
df2.groupby([df2.index.date,df2['Countries']])['Count'].sum().unstack().reindex().plot.bar(ind,ax=ax)
loc=mdates.WeekdayLocator(interval=2)
ax.xaxis.set_major_formatter(mdates.DateFormatter('%m-%d'))
#ax.xaxis.set_major_formatter(mdates.DateFormatter('%b%d'))
ax.xaxis.set_major_locator(loc)
Any help or explanation?