Ajout du choix des dates minimale et maximale pour le graphe
This commit is contained in:
parent
548ff3c522
commit
74f56e813c
@ -3,14 +3,15 @@ set term dumb #nofeed
|
|||||||
set title 'Courbe de poids'
|
set title 'Courbe de poids'
|
||||||
set timefmt "%Y-%m-%d %H:%M:%S"
|
set timefmt "%Y-%m-%d %H:%M:%S"
|
||||||
set xdata time
|
set xdata time
|
||||||
set xmtics
|
#set xmtics
|
||||||
set xlabel "Mois"
|
set xlabel "Mois"
|
||||||
#set xtics format "%Y-%d-%m"
|
#set xtics format "%Y-%d-%m"
|
||||||
|
set xtics format "%m"
|
||||||
set x2data time
|
set x2data time
|
||||||
set x2label "Années"
|
set x2label "Années"
|
||||||
set x2tics format "%Y"
|
set x2tics format "%Y"
|
||||||
set xtics nomirror
|
set xtics nomirror
|
||||||
|
set xrange [*:*]
|
||||||
set datafile separator '|'
|
set datafile separator '|'
|
||||||
plot 'data2.csv' using 3:1 pt '.' title ''
|
plot 'data2.csv' using 3:1 pt '*' title ''
|
||||||
#pause -1 'En attente de RETURN'
|
#pause -1 'En attente de RETURN'
|
||||||
|
17
Fonctionnel.txt_
Normal file
17
Fonctionnel.txt_
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#set term dumb 50 20
|
||||||
|
set term dumb #nofeed
|
||||||
|
set title 'Courbe de poids'
|
||||||
|
set timefmt "%Y-%m-%d %H:%M:%S"
|
||||||
|
set xdata time
|
||||||
|
#set xmtics
|
||||||
|
set xlabel "Mois"
|
||||||
|
#set xtics format "%Y-%d-%m"
|
||||||
|
set xtics format "%m"
|
||||||
|
set x2data time
|
||||||
|
set x2label "Années"
|
||||||
|
set x2tics format "%Y"
|
||||||
|
set xtics nomirror
|
||||||
|
set xrange ['2019-05-01 00:00:00':'2020-10-01 00:00:00']
|
||||||
|
set datafile separator '|'
|
||||||
|
plot 'data2.csv' using 3:1 pt '*' title ''
|
||||||
|
#pause -1 'En attente de RETURN'
|
@ -57,7 +57,7 @@ def save_file_data():
|
|||||||
linenum = 0
|
linenum = 0
|
||||||
for row in contents:
|
for row in contents:
|
||||||
if row.split(' ',1)[0] == 'plot':
|
if row.split(' ',1)[0] == 'plot':
|
||||||
contents.insert(linenum, "plot '"+args.data+"' using 3:1 pt '.' title ''\n")
|
contents.insert(linenum, "plot '"+args.data+"' using 3:1 pt '*' title ''\n")
|
||||||
del(contents[linenum+1])
|
del(contents[linenum+1])
|
||||||
linenum += 1
|
linenum += 1
|
||||||
f = open("Fonctionnel.txt", "w")
|
f = open("Fonctionnel.txt", "w")
|
||||||
@ -139,6 +139,38 @@ def undo_remove():
|
|||||||
|
|
||||||
def trace_graph():
|
def trace_graph():
|
||||||
""" Trace le graphe de l'évolution du poids avec Gnuplot """
|
""" Trace le graphe de l'évolution du poids avec Gnuplot """
|
||||||
|
if args.dates != None:
|
||||||
|
print(args.dates)
|
||||||
|
# set xrange [*:*]
|
||||||
|
f = open("Fonctionnel.txt", "r")
|
||||||
|
contents = f.readlines()
|
||||||
|
f.close()
|
||||||
|
linenum = 0
|
||||||
|
for row in contents:
|
||||||
|
motif = row.split(' ',2)[0]+' '+row.split(' ',2)[1]
|
||||||
|
if motif == 'set xrange':
|
||||||
|
contents.insert(linenum, "set xrange ['"+args.dates[0]+"':'"+args.dates[1]+"']\n")
|
||||||
|
del(contents[linenum+1])
|
||||||
|
linenum += 1
|
||||||
|
f = open("Fonctionnel.txt", "w")
|
||||||
|
contents = "".join(contents)
|
||||||
|
f.write(contents)
|
||||||
|
f.close()
|
||||||
|
else:
|
||||||
|
f = open("Fonctionnel.txt", "r")
|
||||||
|
contents = f.readlines()
|
||||||
|
f.close()
|
||||||
|
linenum = 0
|
||||||
|
for row in contents:
|
||||||
|
motif = row.split(' ',2)[0]+' '+row.split(' ',2)[1]
|
||||||
|
if motif == 'set xrange':
|
||||||
|
contents.insert(linenum, "set xrange [*:*]\n")
|
||||||
|
del(contents[linenum+1])
|
||||||
|
linenum += 1
|
||||||
|
f = open("Fonctionnel.txt", "w")
|
||||||
|
contents = "".join(contents)
|
||||||
|
f.write(contents)
|
||||||
|
f.close()
|
||||||
#process = Popen(['gnuplot', 'Fonctionnel.txt'], stdout=PIPE, stderr=PIPE)
|
#process = Popen(['gnuplot', 'Fonctionnel.txt'], stdout=PIPE, stderr=PIPE)
|
||||||
process = Popen(['gnuplot', 'Fonctionnel.txt'])#, stdout=PIPE, stderr=PIPE)
|
process = Popen(['gnuplot', 'Fonctionnel.txt'])#, stdout=PIPE, stderr=PIPE)
|
||||||
stdout, stderr = process.communicate()
|
stdout, stderr = process.communicate()
|
||||||
@ -209,6 +241,10 @@ parser.add_argument('-g', '--graph',
|
|||||||
help=_('optional : plot graph'),
|
help=_('optional : plot graph'),
|
||||||
action='store_true'
|
action='store_true'
|
||||||
)
|
)
|
||||||
|
parser.add_argument('-ds', '--dates',
|
||||||
|
nargs=2,
|
||||||
|
help=_("optional : date_min date_max ; 'Y-m-d hh:mm:ss'")
|
||||||
|
)
|
||||||
parser.add_argument('-tst', '--tests',
|
parser.add_argument('-tst', '--tests',
|
||||||
help='optional tests operations',
|
help='optional tests operations',
|
||||||
action='store_true'
|
action='store_true'
|
||||||
|
Loading…
Reference in New Issue
Block a user