Advertisement
c0170

Perl & gnuplot

May 22nd, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.92 KB | None | 0 0
  1. # Set variables which set gnu plot properties
  2. @colors_errbars = ("#f08080", "#80f080", "#8080f0");
  3. @colors_points  = ("#ff0000", "#00ff00", "#0000ff");
  4.  
  5. @plt_errbars = (
  6.     'title "button0" with errorbars lw 0.15 pt 1 ps 0.2 lc rgbcolor',
  7.     'title "button1" with errorbars lw 0.15 pt 1 ps 0.2 lc rgbcolor',
  8.     'title "button2" with errorbars lw 0.15 pt 1 ps 0.2 lc rgbcolor'
  9.     );
  10. $plt_points  = 'notitle with points ps 0.2 lc rgbcolor';
  11. $plt_lines   = 'notitle with lines lw 0.1 lc rgbcolor';
  12.  
  13. sub generate_plot
  14. {
  15.     my $plth  = shift;
  16.     my $nfile_size = -s $outfile_name[3];
  17.  
  18.     print $plth 'set xlabel "time [s]" 0,0.5' . "\n";
  19.     print $plth 'set yrange [0:120]' . "\n";
  20.     print $plth 'unset xrange' . "\n";
  21.     print $plth 'set xrange [0:30]' . "\n";
  22.     print $plth 'set autoscale x' . "\n";
  23.     print $plth 'set autoscale y' . "\n";
  24.     print $plth 'set bars 0' . "\n";
  25.     print $plth 'set terminal png size 1680,1050' . "\n";
  26.     print $plth "set output \"$outfile_name[7]\"" . "\n";
  27.     print $plth "set size 1,0.5\n";
  28.  
  29.     if ($nfile_size)
  30.     {
  31.         print $plth "set multiplot layout 3,2 title \"$graph_name\"" . "\n";
  32.     }
  33.     else
  34.     {
  35.         print $plth "set multiplot layout 3,1 title \"$graph_name\"" . "\n";
  36.     }
  37.    
  38.     $max_basic_value += 10; #sets yrange value
  39.  
  40.     for($i=0; $i<3; $i++)
  41.     {
  42.  
  43.         #set only top level title
  44.         if ($i == 0)
  45.         {
  46.             print $plth "set title '$tcase_settings_cap[$outfile-1]' \n";
  47.         }
  48.         else
  49.         {
  50.             print $plth "unset title \n";
  51.         }
  52.  
  53.         print $plth "set yrange [0:$max_basic_value]" . "\n";
  54.  
  55.         #align plots
  56.         print $plth 'set lmargin at screen 0.08' . "\n";
  57.         print $plth 'set ylabel "basic value" -0.5,0' . "\n";
  58.         print $plth "plot ";
  59.         print $plth "\"$outfile_name[$i]\" $plt_errbars[$i] \"$colors_errbars[$i]\"";
  60.  
  61.         print $plth ",";
  62.         print $plth "\"$outfile_name[$i]\" $plt_lines  \"$colors_points[$i]\"";
  63.         print $plth ' ' . "\n";
  64.  
  65.         #only if second data are available
  66.         if ($nfile_size)
  67.         {
  68.             # Set only top level title
  69.             if ($i == 0)
  70.             {
  71.                 print $plth "set title '$tcase_settings_second[$outfile-1]' \n"; #name for second column
  72.             }
  73.             else
  74.             {
  75.                 print $plth "unset title \n";
  76.             }
  77.  
  78.             print $plth 'set yrange [0:16]' . "\n";
  79.             print $plth 'set lmargin at screen 0.55' . "\n";
  80.             print $plth 'set ylabel "advanced value" -0.5,0' . "\n";
  81.             print $plth "plot ";
  82.             print $plth "\"$outfile_name[$i+3]\" $plt_errbars[$i] \"$colors_errbars[$i]\"";
  83.  
  84.             print $plth ",";
  85.             print $plth "\"$outfile_name[$i+3]\" $plt_lines  \"$colors_points[$i]\"";
  86.             print $plth ' ' . "\n";
  87.         }
  88.     }
  89.     print $plth "unset multiplot\n";
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement