Bonjour,
J'essaye d'apprendre à utiliser Matplotlib, mais je n'arrive pas à faire fonctionner une fonction. Voilà mon code :
import matplotlib.pyplot as plt
days = [1,2,3,4,5]
sleeping = [7,8,6,10,7]
eating = [2,3,4,3,2]
working = [7,8,7,2,2]
playing = [8,5,7,6,4]
plt.stackplot(days, sleeping, eating, working, playing) #erreur ici
plt.xlabel('x')
plt.ylabel('y')
plt.title("cool graph\nCheck it out")
plt.legend()
plt.show()
def test(x, *args):
print(x)
print([arg for i in args])
test(5,7,8,9)
Lorsque j'appelle la fonction stackplot, j'ai l'erreur suivante : stackplot() got multiple values for argument 'x'
Voilà le prototype de stackplot : https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.stackplot.html
Et ma fonction test ne retourne pas d'erreur.
Donc je ne comprends pas pourquoi ça me détecte plusieurs argument pour x. J'ai essayer d'autre chose, comme mettre les arguments qui suivent x dans une liste, ou mettre qu'un entier à la place de x, ou écrire plt.stackplot(days, args = [sleeping, eating, working, playing])
Mais j'ai toujours une erreur... Des idées ?