Commit 34fdbb69 authored by MARTINEZ Thierry 's avatar MARTINEZ Thierry

Plot

parent e47e8ae3
......@@ -19,7 +19,7 @@ numerical_simulation(Time) :-
doc('performs a numerical simulation up to a given time.'),
compute_ode,
make_ode_system,
solve.
solve(Time).
make_ode_system :-
......@@ -27,7 +27,7 @@ make_ode_system :-
convert_ode.
solve :-
solve(Time) :-
gather_headers(Headers),
gather_equations(Equations),
gather_initial_values(InitialValues),
......@@ -42,7 +42,7 @@ solve :-
initial_step_size: 1e-6,
precision: 5,
time_initial: 0,
time_final: 100
time_final: Time
],
solve(Options, Table),
add_trace('numerical_simulation', Table).
......
......@@ -23,22 +23,35 @@ export_plot(FileTemplate) :-
format(atom(PlotFile), '~a.plot', [FileTemplate]),
format(atom(CsvFile), '~a.csv', [FileTemplate]),
export_trace(CsvFile),
get_trace_data([HeaderRow | _ ]),
HeaderRow =.. [row, _TimeHeader | Headers],
setup_call_cleanup(
open(PlotFile, write, Stream),
export_plot_stream(Stream, CsvFile),
export_plot_stream(Stream, CsvFile, Headers),
close(Stream)
).
export_plot_stream(Stream, CsvFile) :-
format(Stream, '\c
export_plot_stream(Stream, CsvFile, Headers) :-
write(Stream, '\c
set style data lines
set format y "%g"
set xrange [*:*]
set yrange [*:*]
set ytics nomirror autofreq
set xtics nomirror
set mxtics default
set key outside Left reverse
set datafile separator ","
plot "~a"
', [CsvFile]).
plot '),
\+ (
nth1(Index, Headers, Header),
\+ (
(
Index > 1
->
write(Stream, ', ')
;
true
),
ColumnIndex is Index + 1,
format(
Stream,
'"~a" using 1:~d title "~a"',
[CsvFile, ColumnIndex, Header]
)
)
),
write(Stream, '\n').
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment