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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
import csv
import numpy
import pandas
import PIL
import os
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import matplotlib.pyplot as plt
import re
# im = Image.new("RGBA", (400,400),(255,255,255,0))
#
# I1 = ImageDraw.Draw(im)
# I1.text((28, 36), "nice Car", fill=(255, 0, 0))
# im.show()
# myFont = ImageFont.truetype('FreeMono.ttf', 45)
df = pandas.read_csv('4xv4.csv')
os.makedirs("repfin", exist_ok=True)
os.chdir("repfin")
#on definit vitmax, hrmax et le nb de lignes
nbligne = len(df.axes[0])
nbli = [i for i in range(1,nbligne)]
# print(nbli)
vitmax = df['vit'].max()
hrmax = df['HR'].max()
#on écrit les images
for i in nbli :
plt.subplot(222)
plt.plot(df['datesec'],df['HR'], color='b')
plt.plot(df['datesec'][i],df['HR'][i],marker='s', color='r')
plt.subplot(224)
# plt.plot(df['datesec'],df['vit'])
plt.bar(1,vitmax, color = '#3ED8C9')
plt.bar(1,df['vit'][i], color = '#EDFF91')
aff = str(df['vit'][i])+" km/h"
plt.text(10,10,aff, fontsize=20, color='b')
plt.subplot(121)
plt.plot(df['lon'],df['lat'], color = 'b')
plt.plot(df['lon'][i],df['lat'][i], marker ='s', color = 'r')
plt.axis("equal")
nom = str(i)+".png"
plt.show()
plt.savefig(nom)
plt.clf()
print("done") |
Partager