0

I have a multi index data for test & training accuracy for two models. I want to show the models in stacked bar for both metric in same chart. Somehow I managed to do it but I can not set labels for the metrics.

enter image description here

As can be seen above, I have 4 stacked bars. Left group is model A & B for training accuracy, right group is model A & B for test accuracy. Is there any way to set labels? I tried patches but it did not work.

Here is the code:

matplotlib.style.use("seaborn-white")
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(18,8))
ax_position = 0
y_offset = -5 # decrease value if you want to decrease the position of data labels
plt.suptitle("Test Accuracy", size=25, y=1.05)
ax = a1.plot(position=0.1, kind="bar", stacked=True, cmap=cmap1,
                     ax=axes[ax_position], width=0.2)
ax = a2.plot(position=0.8, kind="bar", stacked=True, cmap=cmap1,
                     ax=axes[ax_position], width=0.2)
ax.set_xticklabels(labels=["1", "2"], fontsize=15)
ax.legend().set_visible(False)
koftezz
  • 33
  • 3

0 Answers0