0

I can plot a 100% stacked bar from Excel. is it possible to achieve the same with matplotlib ?

enter image description here

enter image description here

import pandas as pd
import matplotlib.pyplot as plt

data = [
        [0.4 , 0.3 , 0.2 , 0.1],
        [0.5 , 0.3 , 0.6 , 0.1],
        [0.1 , 0.4 , 0.2 , 0.8],
        
]

columns = ["A","B","C","D" ]

df = pd.DataFrame(data=data , columns=columns , index = ["Empty" , "Wrong" , "Correct"] )

df.plot(kind="barh" , stacked=True )

plt.ylabel("Percentages")

plt.show()

print (df)

0 Answers0