Commit 9287eb77 authored by MARTINEZ Thierry 's avatar MARTINEZ Thierry

Plot to PNG

parent 31a2f278
......@@ -2,24 +2,40 @@
plot,
[
plot/0,
export_plot/1
export_plot/1,
export_plot_to_png/1
]
).
plot :-
biocham_command,
doc('plots the current trace.'),
export_plot(plot),
process_create(path(gnuplot), ['-persist', 'plot.plot'], []).
execute_plot(['-persist', 'plot.plot']).
execute_plot(Options) :-
process_create(path(gnuplot), Options, []).
export_plot(FileTemplate) :-
biocham_command,
doc('
saves the numerical trace of the last simulation into two files:
saves the current trace into two files:
\\argument{FileTemplate}\\texttt{.csv} and \\texttt{.plot}.
'),
export_plot(FileTemplate, []).
export_plot_to_png(OutputFile) :-
biocham_command,
type(OutputFile, output_file),
doc('plots the current trace in a PNG file'),
export_plot(plot, [png(OutputFile)]),
execute_plot(['plot.plot']).
export_plot(FileTemplate, Options) :-
format(atom(PlotFile), '~a.plot', [FileTemplate]),
format(atom(CsvFile), '~a.csv', [FileTemplate]),
export_trace(CsvFile),
......@@ -27,11 +43,21 @@ export_plot(FileTemplate) :-
HeaderRow =.. [row, _TimeHeader | Headers],
setup_call_cleanup(
open(PlotFile, write, Stream),
export_plot_stream(Stream, CsvFile, Headers),
export_plot_stream(Stream, CsvFile, Headers, Options),
close(Stream)
).
export_plot_stream(Stream, CsvFile, Headers) :-
export_plot_stream(Stream, CsvFile, Headers, Options) :-
(
member(png(Filename), Options)
->
format(Stream, '\c
set term png
set output "~a"
', [Filename])
;
true
),
write(Stream, '\c
set style data lines
set datafile separator ","
......
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