I have a graph with 8 subplots. Each subplot is a bar graph with two classes, spruce beetle and mountain pine beetle. In all the subplots spruce beetle comes before mountain pine beetle except for the fourth subplot (2017 Fire Year). Why is this?
Is there a way to make the 2017 fire plot have spruce beetle come before mountain pine beetle? Thanks in advance.
fig, axes = plt.subplots(8, figsize=(12,16), dpi=100)
# list of axes
axelocs = [axes[0], axes[1], axes[2], axes[3], axes[4], axes[5], axes[6], axes[7]]
dfs = [df_2020, df_2019, df_2018, df_2017, df_2016, df_2015, df_2013, df_2012]
labels = ['2020 Fire Year', '2019 Fire Year', '2018 Fire Year', '2017 Fire Year', '2016 Fire Year', '2015 Fire Year', '2013 Fire Year', '2012 Fire Year']
# generate each axe
for axeloc, df, label in zip(axelocs, dfs, labels):
palette = {'Spruce Beetle': '#97BC62FF', 'Mountain Pine Beetle': '#2C5F2D'}
sns.barplot(ax=axeloc,
x='SURVEY_YEA',
y='Hectares',
hue='DCA_COMMON',
linewidth=0,
data=df,
palette=palette,
).set(title=label,
ylabel=None,
xlabel=None)
axeloc.legend([],[], frameon=False)
axelocs[0].legend()
fig.suptitle('Burned Beetle-Kill', fontsize=16, fontweight='bold')
fig.supxlabel('Year')
fig.supylabel('Hectares')
plt.tight_layout()
plt.show()