'Pandas Bar plot for each row and grouped by columns
I have Pandas Dataframe of evaluation metrics for different models
Model A Model B Model C
precision 0.946599 0.966482 0.990482
specificity 0.763636 0.854545 0.963636
sensitivity 0.938776 0.938776 0.857143
roc_auc 0.953061 0.953247 0.937662
acc 0.906667 0.923333 0.876667
balanced_acc 0.851206 0.89666 0.91039
f1_score 0.907219 0.925068 0.88695
I would like to generate a bar plot for each of the rows and grouped by columns in one plot (something like below, which I generated using google spreadsheet)
Solution 1:[1]
import matplotlib.pyplot as plt
plt.style.use('seaborn-white')
ax = df.plot.bar(figsize=[12, 7])
ax.legend(bbox_to_anchor=(0,1.02,1,0.2), loc="lower center", ncol=3, fontsize=16)
ax.set_xticklabels(ax.get_xticklabels(), rotation=0)
ax.tick_params(axis='both', labelsize=14)
ax.set_xlabel("X-axis", fontsize=16)
ax.set_ylabel("Y-axis", fontsize=16)
ax
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | d.b |


