Echanges autour d'EduPython.
Vous n'êtes pas identifié(e).
Pages : 1
Bonjour,
Dans les nouveaux programmes de Physique-Chimie les élèves doivent représenter des trajectoires, des vecteurs Vitesse, des variations de vecteurs Vitesse grâce à un langage de programmation.
J'ai fait quelques essais avec Matplotlib et j'ai rusé en détournant les flèches prévues pour les annotations mais je suppose qu'il existe d'autres moyens.
Merci pour vos pistes, vos idées.
t = [0,0.04,0.08,0.12,0.16,0.2,0.24,0.28,0.32,0.36,0.4,0.44,0.48,0.52,0.56,0.6,0.64,0.68,0.72,0.76,0.8,0.84,0.88,0.92] x = [2.386206897,2.593103448,2.8,3.020689655,3.213793103,3.434482759,3.64137931,3.820689655,4.027586207,4.234482759,4.427586207,4.634482759,4.84137931,5.034482759,5.24137931,5.434482759,5.627586207,5.820689655,6.027586207,6.220689655,6.427586207,6.606896552,6.813793103,7.020689655] y = [2.910344828,3.144827586,3.365517241,3.55862069,3.737931034,3.903448276,4.055172414,4.193103448,4.303448276,4.4,4.496551724,4.565517241,4.620689655,4.662068966,4.689655172,4.703448276,4.675862069,4.662068966,4.634482759,4.579310345,4.510344828,4.44137931,4.331034483,4.234482759] vx = [] vy = [] tModif = [] for i in range(1,len(t)-1) : vx.append((x[i+1]-x[i-1])/0.08) vy.append((y[i+1]-y[i-1])/0.08) tModif.append(t[i]) # pyplot.annotate('', xy = (x[i]+vx[i-1]/20, y[i]+vy[i-1]/20), xytext = (x[i], y[i]), arrowprops = {'edgecolor': 'blue','width': 1, 'headwidth': 3}) for i in range(1,len(vx)-1) : # pyplot.annotate('', xy = (x[i+1]+vx[i+1]/10, y[i+1]+vy[2]/10), xytext = (x[i+1], y[i+1]), arrowprops = {'edgecolor': 'blue','width': 1, 'headwidth': 3}) # pyplot.annotate('', xy = (x[i+1]+vx[i+1]/10-vx[i-1]/10, y[i+1]+vy[i+1]/10-vy[i-1]/10), xytext = (x[i+1]+vx[i+1]/10, y[i+1]+vy[i+1]/10), arrowprops = {'edgecolor': 'blue','width': 1, 'headwidth': 3}) pyplot.annotate('', xy = (x[i+1]+vx[i+1]/10-vx[i-1]/10, y[i+1]+vy[i+1]/10-vy[i-1]/10), xytext = (x[i+1], y[i+1]), arrowprops = {'edgecolor': 'green','width': 1, 'headwidth': 3}) pyplot.scatter(x, y, c = 'red', marker = '+') pyplot.show()
Hors ligne
Bonjour,
Finalement j'ai trouvé la fonction arrow.
Voici le code final pour les collègues intéressés.
t = [0,0.04,0.08,0.12,0.16,0.2,0.24,0.28,0.32,0.36,0.4,0.44,0.48,0.52,0.56,0.6,0.64,0.68,0.72,0.76,0.8,0.84,0.88,0.92] x = [2.386206897,2.593103448,2.8,3.020689655,3.213793103,3.434482759,3.64137931,3.820689655,4.027586207,4.234482759,4.427586207,4.634482759,4.84137931,5.034482759,5.24137931,5.434482759,5.627586207,5.820689655,6.027586207,6.220689655,6.427586207,6.606896552,6.813793103,7.020689655] y = [2.910344828,3.144827586,3.365517241,3.55862069,3.737931034,3.903448276,4.055172414,4.193103448,4.303448276,4.4,4.496551724,4.565517241,4.620689655,4.662068966,4.689655172,4.703448276,4.675862069,4.662068966,4.634482759,4.579310345,4.510344828,4.44137931,4.331034483,4.234482759] vx = [] vy = [] tModif = [] for i in range(1,len(t)-1) : vx.append((x[i+1]-x[i-1])/0.08) vy.append((y[i+1]-y[i-1])/0.08) tModif.append(t[i]) print("La valeur maximale pour vx est",max(vx),"m/s.") print("La valeur maximale pour vy est",max(vy),"m/s.") echelle = float(input("Choisir une échelle : 1 m pour ... m/s.")) for i in range(1,len(vx)-1) : # pyplot.arrow(x[i+1], y[i+1], vx[i+1]/20, vy[i+1]*echelle , color = 'blue', head_width = 0.02, length_includes_head = True) # pyplot.arrow(x[i+1]+vx[i+1]*echelle, y[i+1]+vy[i+1]*echelle, -vx[i-1]*echelle, -vy[i-1]*echelle , color = 'green', head_width = 0.02, length_includes_head = True) pyplot.arrow(x[i+1], y[i+1], vx[i+1]*echelle-vx[i-1]*echelle, vy[i+1]*echelle-vy[i-1]*echelle ,color = 'red', head_width = 0.02, length_includes_head = True) pyplot.scatter(x, y, c = 'red', marker = '+') pyplot.show()
Hors ligne
Merci pour l'information.
Bonne journée,
Vincent
Hors ligne
Pages : 1