Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1448 connectés 

  FORUM HardWare.fr
  Programmation
  Python

  unrecognized character in %c format string %c

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

unrecognized character in %c format string %c

n°2261795
smooz
Posté le 04-07-2015 à 11:52:49  profilanswer
 

Bonjour,  
j'ai écrit un programme d'Euler à la suite duquel j'essaie d'afficher les courbes mais tout ce que j'obtiens est le message d'erreur suivant :
 
Traceback (most recent call last):
  File "<string>", line 250, in run_nodebug
  File "E:\PSI-Info.py", line 65, in <module>
    plt.plot(x,y,'Pression interne')
  File "D:\Matthieu_Data\Bibliothèques\Bureau\EduPython\App\lib\site-packages\matplotlib\pyplot.py", line 2987, in plot
    ret = ax.plot(*args, **kwargs)
  File "D:\Matthieu_Data\Bibliothèques\Bureau\EduPython\App\lib\site-packages\matplotlib\axes.py", line 4139, in plot
    for line in self._get_lines(*args, **kwargs):
  File "D:\Matthieu_Data\Bibliothèques\Bureau\EduPython\App\lib\site-packages\matplotlib\axes.py", line 319, in _grab_next_args
    for seg in self._plot_args(remaining, kwargs):
  File "D:\Matthieu_Data\Bibliothèques\Bureau\EduPython\App\lib\site-packages\matplotlib\axes.py", line 278, in _plot_args
    linestyle, marker, color = _process_plot_format(tup[-1])
  File "D:\Matthieu_Data\Bibliothèques\Bureau\EduPython\App\lib\site-packages\matplotlib\axes.py", line 131, in _process_plot_format
    'Unrecognized character %c in format string' % c)
ValueError: Unrecognized character P in format string
 
Voilà le programme :
 
def liste():
    T=[]
    a=0
    for i in range(100):
        a=i+1
        T.append(a)
    return T
 
from math import cos
from math import sin
 
a=2
K=1
Vo=1
h=1
S=2
w=1
e=1
A=1
 
 
def F(y,t):
    return a*y*((-K*(y-10**5)/(Vo-h*S*A*cos(w*t))*(1-e*(1-(y/(10**5))**a)))-((h*S*A*w*sin(w*t))/(Vo-h*S*A*cos(w*t))))
 
def Euler(F,yo,T):
    N=len(T)
    y=[0]*N
    y[0]=yo
    for i in range(N-1):
        y[i+1]=y[i]+(T[i+1]-T[i])*F(y[i],T[i])
    return y
 
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(0,100,100)
y=Euler(F,1,T)
plt.plot(x,y,'Pression interne')
 
Apparemment le problème vient de mon utilisation de matplotlib mais je ne vois pas du tout comment le résoudre.

mood
Publicité
Posté le 04-07-2015 à 11:52:49  profilanswer
 

n°2261826
Jubijub
Parce que je le VD bien
Posté le 05-07-2015 à 10:48:00  profilanswer
 

utilise les balises [ code ] [ /code] (sans les espaces)
 

Code :
  1. def liste():
  2.    T=[]
  3.    a=0
  4.    for i in range(100):
  5.        a=i+1
  6.        T.append(a)
  7.    return T
  8.  
  9. from math import cos
  10. from math import sin
  11.  
  12. a=2
  13. K=1
  14. Vo=1
  15. h=1
  16. S=2
  17. w=1
  18. e=1
  19. A=1
  20.  
  21.  
  22. def F(y,t):
  23.    return a*y*((-K*(y-10**5)/(Vo-h*S*A*cos(w*t))*(1-e*(1-(y/(10**5))**a)))-((h*S*A*w*sin(w*t))/(Vo-h*S*A*cos(w*t))))
  24.  
  25. def Euler(F,yo,T):
  26.    N=len(T)
  27.    y=[0]*N
  28.    y[0]=yo
  29.    for i in range(N-1):
  30.        y[i+1]=y[i]+(T[i+1]-T[i])*F(y[i],T[i])
  31.    return y
  32.  
  33. import numpy as np
  34. import matplotlib.pyplot as plt
  35. x=np.linspace(0,100,100)
  36. y=Euler(F,1,T)
  37. plt.plot(x,y,'Pression interne')


---------------
Jubi Photos : Flickr - 500px
n°2261858
Soileh
Lurkeur professionnel
Posté le 05-07-2015 à 20:37:24  profilanswer
 

:hello: !
 
Pour t'aider à résoudre ton problème, voici un extrait de l'aide sur la fonction depuis ce site :

Citation :


 matplotlib.pyplot.plot(*args, **kwargs)
 
    Plot lines and/or markers to the Axes. args is a variable length argument, allowing for multiple x, y pairs with an optional format string.


Je pense que c'est l'utilisation de la fonction plot( ) qui n'est pas adéquate : à la place de 'Pression interne', tu dois indiquer une chaîne de caractères précisant le format du tracé.
 
:jap:


---------------
And in the end, the love you take is equal to the love you make

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Python

  unrecognized character in %c format string %c

 

Sujets relatifs
Convertir un string en nom de variable ? (parseJSON)Affichage d'une date en format "dd-MM-yyyy"
Convertir un String en Dateequivalence mysql_escape_string en PDO
(FFmpeg-PHP)Comment passer d'un format à un autreHTML/CSS Probleme de format Besoin d'aide !!!
Récupérer dans des text/Combo Box le format du doc word[Help] Optimisattion concaténation de string
Suppression ligne en fonction du format d'une cellule 
Plus de sujets relatifs à : unrecognized character in %c format string %c


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR