Skip to content

Instantly share code, notes, and snippets.

@drvenabili
Created April 4, 2018 12:45
Show Gist options
  • Save drvenabili/86ce7fd9be2063e8676e0a79a6d722a5 to your computer and use it in GitHub Desktop.
Save drvenabili/86ce7fd9be2063e8676e0a79a6d722a5 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
valeurs = {"p1":[0.4, 0.55, 0.05, 0.0], "p2":[0.2, 0.3, 0.5, 0.0], "p3":[0.4, 0.2, 0.2, 0.2], "p4":[0.2, 0.2, 0.2, 0.4], "p5":[0.4, 0.55, 0.05, 0.0], "p6":[0.4, 0.55, 0.05, 0.0], "p7":[0.4, 0.55, 0.05, 0.0]}
colours = ['b','g','r','c','m','y','k']
valeurs2 = dict()
for key in valeurs.keys():
#print(key)
list_temp = list()
for item in valeurs[key]:
list_temp.append(int(item*100))
valeurs2[key] = list_temp
#for value in valeurs
for key,vals in valeurs2.items():
print(key,vals)
for i in range(0,len(vals)):
if i == 0:
previous = 0
plt.bar(x=key, height=vals[i],bottom=previous,color=colours[i])
else:
previous = vals[i-1] + previous
plt.bar(x=key, height=vals[i],bottom=previous,color=colours[i])
plt.xticks(range(len(valeurs2)), valeurs2.keys())
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment