Add a function to do plots with any channel being X and any other channel
being "Y".
This commit is contained in:
parent
d535c7c6b1
commit
e7bdd8deeb
1 changed files with 38 additions and 1 deletions
|
@ -134,7 +134,7 @@ sub stop_logging {
|
|||
}
|
||||
|
||||
|
||||
sub quick_plot {
|
||||
sub quick_plot_vs_time {
|
||||
my( $data_file ) = shift;
|
||||
my( $plot_file ) = shift;
|
||||
my( $title ) = shift;
|
||||
|
@ -169,4 +169,41 @@ sub quick_plot {
|
|||
}
|
||||
|
||||
|
||||
sub quick_plot {
|
||||
my( $data_file ) = shift;
|
||||
my( $plot_file ) = shift;
|
||||
my( $xtitle ) = shift;
|
||||
my( $ytitle ) = shift;
|
||||
my( $xcolumn ) = shift;
|
||||
my( $ycolumn ) = shift;
|
||||
|
||||
print "quick plot -> $plot_file\n";
|
||||
|
||||
my( $tmpcmd ) = "$tmp_dir/plot_cmd_tmp.$$";
|
||||
my( $tmpdata ) = "$tmp_dir/plot_data_tmp.$$";
|
||||
my( $png_image ) = "$plot_file.png";
|
||||
|
||||
# strip the leading header off the file so gnuplot doesn't squawk
|
||||
system( "tail +2 $data_file | sed -e \"s/,/ /g\" > $tmpdata" );
|
||||
|
||||
# create the gnuplot command file
|
||||
open( CMD, ">$tmpcmd" );
|
||||
print CMD "set terminal png color\n";
|
||||
print "png_image = $png_image\n";
|
||||
print CMD "set output \"$png_image\"\n";
|
||||
print CMD "set xlabel \"$xtitle\"\n";
|
||||
print CMD "set ylabel \"$ytitle\"\n";
|
||||
print CMD "plot \"$tmpdata\" using $xcolumn:$ycolumn title \"$xtitle vs. $ytitle\" with lines\n";
|
||||
print CMD "quit\n";
|
||||
close( CMD );
|
||||
|
||||
# plot the graph
|
||||
system( "gnuplot $tmpcmd" );
|
||||
|
||||
# clean up all our droppings
|
||||
unlink( $tmpcmd );
|
||||
unlink( $tmpdata );
|
||||
}
|
||||
|
||||
|
||||
return 1; # make perl happy
|
||||
|
|
Loading…
Add table
Reference in a new issue