import numpy as np import matplotlib.pyplot as plt import pymysql # ... SELECT connection = pymysql.connect( host="sql25.phpnet.org", user="msb77833", password="GLSb0uhU5W3E", db="msb77833") cursor = connection.cursor() cursor.execute("SELECT identifiant, nombre * cours_achat AS value FROM t_mouvement;") result = cursor.fetchall() # record = cursor.fetchone() # convertir result en labels et data print(result) labels = [] data = [] for ligne in result: labels.append(ligne[0]) data.append(ligne[1]) print(labels) print(data) # afficher graphique # labels = cursor.fetchone # data = cursor.fetchall # women_means = [25, 32, 34, 20, 25] # men_std = [2, 3, 4, 1, 2] # women_std = [3, 5, 2, 3, 3] width = 0.50 # the width of the bars: can also be len(x) sequence fig, ax = plt.subplots() ax.bar(labels, data, width, label='Position' ) # yerr=men_std, ) # ax.bar(labels, women_means, width, yerr=women_std, bottom=men_means, # label='Women') ax.set_ylabel('Valeur des positions') ax.set_xlabel('Positions') ax.set_title('Mouvements depuis database') # ax.legend() plt.show()