Mis a jour le 2024-03-17, 13:2

Pie / camembert

Camembert simple : pyplot.pie(x, labels = ['A', 'B', 'C', 'D', 'E'], normalize = True). pyplot.figure(figsize = (8, 8)) x = [1, 2, 3, 4, 10] pyplot.pie(x, labels = ['A', 'B', 'C', 'D', 'E'], normalize = True) pyplot.legend() Différents paramètres :
On peut empêcher la normalisation en dessinant des camemberts incomplets, avec une somme de valeur plus petite que 1 : pyplot.figure(figsize = (8, 8)) x = [0.1, 0.2, 0.3, 0.1] pyplot.pie(x, labels = ['A', 'B', 'C', 'D'], normalize = False) pyplot.legend()
Exemple plus complet : pyplot.figure(figsize = (8, 8)) x = [1, 2, 3, 4, 10] pyplot.pie(x, labels = ['A', 'B', 'C', 'D', 'E'], colors = ['red', 'green', 'yellow'], explode = [0, 0.2, 0, 0, 0], autopct = lambda x: str(round(x, 2)) + '%', pctdistance = 0.7, labeldistance = 1.4, shadow = True) pyplot.legend()

Copyright python-simple.com
programmer en python, tutoriel python, graphes en python, Aymeric Duclert