fig, axes = plt.subplots(8, figsize=(12,16), dpi=100)
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']
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()
CodePudding user response:
Force hue_order
of your variables:
sns.barplot(ax=axeloc,
x='SURVEY_YEA',
y='Hectares',
hue='DCA_COMMON',
linewidth=0,
data=df,
palette=palette,
hue_order=['Spruce Beetle', 'Mountain Pine Beetle']
).set(title=label,
ylabel=None,
xlabel=None)