From e7bdd8deeb500a6e3665f6fec89bf339bda3047c Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 27 Feb 2004 23:28:23 +0000 Subject: [PATCH] Add a function to do plots with any channel being X and any other channel being "Y". --- scripts/perl/examples/logging.pl | 39 +++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/scripts/perl/examples/logging.pl b/scripts/perl/examples/logging.pl index b951b3a28..5aeda6586 100755 --- a/scripts/perl/examples/logging.pl +++ b/scripts/perl/examples/logging.pl @@ -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 -- 2.39.5