I have a bar plot that shows which kind of bacteria does each group have, I want to add a legend and values in that legend must be in italic (Firmicutes, Actinobacteriota etc). How can I do that?
My code right now:
fields = ['Firmicutes', 'Actinobacteriota', 'Proteobacteria', 'Bacteroidota', 'unclassified', 'Other']
colors = ['#1D2F6F', '#8390FA', '#6EAF46', '#FAC748', '#d43737', '#b751d6']
labels = ['Firmicutes', 'Actinobacteriota', 'Proteobacteria', 'Bacteroidota', 'unclassified', 'Other']
fig, ax = plt.subplots(1, figsize=(13,10))
bottom = len(df2_grouped_phyl) * [0]
for idx, name in enumerate(fields):
plt.bar(df2_grouped_phyl.index, df2_grouped_phyl[name], bottom = bottom, color = colors[idx], linewidth = 0.5)
bottom = bottom + df2_grouped_phyl[name]
plt.legend(labels, bbox_to_anchor=([1,1,0,0]), ncol=1, frameon=True)
ax.grid(axis='y', alpha=0.4)
plt.xlabel('Grupp')
plt.ylabel('Protsent')
ax.spines['right'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['bottom'].set_visible(False)
plt.ylim(1)
ax.set_axisbelow(True)
ax.xaxis.grid(color='gray',linestyle='dashed')
plt.show()