1 pièce(s) jointe(s)
Affichage de plusieurs figures dans une seule figure Matplotlib
Bonjour ,
J'ai écrit le code suivant qui me donne plusieurs figures chacune à part, je veux les afficher dans une seule figure (une seule fenêtre) sachant que le nombre de figures est inconnu.
Autre problème, y a t-il un moyen pour configurer l'axe x par pas ( Exemple: de 0 à 4 avec pas de 0.5 ==> [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4] ) puisque quelques barres dans quelques figures sont collés comme montre la photo suivante
Je vous remercie par avance.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| for i in range(len(D)):
x = []
y = []
labels = []
titles = D[i][0][0]
for iat in range(1,len(D[i])):
labels.append(D[i][iat][0])
x.append(D[i][iat][1])
y.append(D[i][iat][2])
ax = plt.subplot()
rects = ax.bar(x,y,width = 0.1, color = 'b', align = 'center', alpha = 0.5)
ax.set_ylabel('Coord')
ax.set_xlabel('Dist')
patch = matplotlib.patches.Patch(color = 'b', label = titles)
plt.legend(handles=[patch])
ax.set_title(Name)
ax.set_xticks(x)
ax.set_xticklabels([i for i in x] , rotation='vertical')
rects = ax.patches
for rect,label in zip(rects,labels):
height = rect.get_height()
ax.text(rect.get_x() + rect.get_width()/2., height + 0.1 ,label, ha ='center', va ='bottom')
plt.show()
width = 0.4
xlocations = np.array(range(len(occ)))+0.5
bar(xlocations, ocu, width, color ='b', align = 'center', alpha = 0.5)
xticks(xlocations + width/2, natom)
title("occ")
show() |
Pièce jointe 287644