Bonjour à tous,
J'utilise, Python 3.6 avec Anaconda et spider et je suis nouveau avec l'utilisation de Python.
Hier j'ai écrit un code qui fonctionné:
j'ai quitté et éteint mon ordinateur, ce matin je le rallume et voici les erreurs:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import matplotlib import matplotlib.pyplot as plt #definition of x and y x = array([1, 3, 4, 6]) y = array([2, 3, 5, 1]) y2=cos(x) fig = plt.figure() plot(x, y,"r", label='triangle') plot(x,y2,"b:o", label='cos') plot(x3,y3, label='Loaded from file!') title("courbe") legend() xlabel('X') ylabel('Y') # ##Outpur the plots #show() fig.savefig('testpylab.png')
Je n'ai rien touché entre-temps juste fermé et éteint..
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 x = array([1, 3, 4, 6]) NameError: name 'array' is not defined
De même avec un autre code qui fonctionné hier avant de fermer et éteindre:
ce matin j'obtiens cette erreur;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 import matplotlib import matplotlib.pyplot as plt a=np.loadtxt('mon.txt', skiprows=1, usecols=range(1,30)) som=a[1,:]+a[2,:] cur=a[2,:] sa=a[1,:] sa2=a[1,:]+a[2,:] sa2[0]=0 for i in range(len(som)-1): sa2[i+1]=abs(som[i+1]-som[i]) x = range(29) fig = plt.figure() plot(x, sa2,"r", label='sa2') plot(x, som,"b", label='Somme') plot(x, cur,"g", label='Cur') plot(x, Sa,"y:o", label='Sa') legend() xlabel('Temps') ylabel('Valeur') fig.savefig('test.png')
Y a eut une mise à jour des librairies entre-temps ou ..??
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 plot(x, sa2,"r", label='sa2') NameError: name 'plot' is not defined <matplotlib.figure.Figure at 0x116a3f6d8>
Là je suis vraiment sans idée ..
Partager