# Defining colors palette np.random.seed(42) df_plot = df[['month', 'day_str', 'PJME_MW', 'day']].dropna().groupby(['day_str', 'month', 'day']).mean()[['PJME_MW']].reset_index() df_plot = df_plot.sort_values(by='day', ascending=True) months = df_plot['month'].unique() colors = np.random.choice(list(mpl.colors.XKCD_COLORS.keys()), len(months), replace=False) # Plot plt.figure(figsize=(16,12)) for i, y in enumerate(months): if i > 0: plt.plot('day_str', 'PJME_MW', data=df_plot[df_plot['month'] == y], color=colors[i], label=y) if y == 2018: plt.text(df_plot.loc[df_plot.month==y, :].shape[0]-.9, df_plot.loc[df_plot.month==y, 'PJME_MW'][-1:].values[0], y, fontsize=12, color=colors[i]) else: plt.text(df_plot.loc[df_plot.month==y, :].shape[0]-.9, df_plot.loc[df_plot.month==y, 'PJME_MW'][-1:].values[0], y, fontsize=12, color=colors[i]) # Setting Labels plt.gca().set(ylabel= 'PJME_MW', xlabel = 'Month') plt.yticks(fontsize=12, alpha=.7) plt.title("Seasonal Plot - Weekly Consumption", fontsize=20) plt.ylabel('Consumption [MW]') plt.xlabel('Month') plt.show()