I am trying to change the legend on this bar chart from numbers into the months of the year but I want to keep the months ordered (i.e. from January to December).
This is what I've tried and the legend doesn't change when taking the last line of code out or putting it in. I have also tried using legend = (['January','February',...)]
as an argument in .plot.bar()
.
df = pd.read_csv('fcc-forum-pageviews.csv', index_col = 'date')
df.index = pd.to_datetime(df.index)
df_group = df.groupby(['Years', 'Months'])['value'].mean()
df_group = df_group.unstack()
fig = df_group.plot.bar(figsize = (10,7), legend = True, ylabel = 'Average Page Views', xlabel = 'Years').figure
plt.legend = (['January','February','March','April','May','June','July','August', 'September', 'October', 'November','December'])
It also might be worth mentioning that I am testing this in jupyterlabs. I am new to matplotlib and pandas so apologies if this seems stupid.
This is task 2 for reference: