#!/usr/bin/perl
#
# Make plots for the MACHO RR0 Lyr paper
  
  my($output_file, $term_options);



  # get the arguments

  $output_file = "linsolve_time_a.ps";
  $term_options = "postscript color enhanced font 'Helvetica,18' ";

  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set key top right \n";
  printf CMDFILE "set xlabel 'Number of Elements'  \n";
  printf CMDFILE "set ylabel 'Time to solve equation (s)' \n";
  printf CMDFILE "set logscale x \n";
  printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set title 'Stars in the MACHO RR0 Lyr catalog'\n";
  
  $cmd = "plot [3:200][] ";
  $cmd .= " 'time_test_1.dat' ";
  $cmd .= "    using (\$2):(\$6) with points  t '' lw 1.5 pt 3 ";


  printf CMDFILE "$cmd \n";
  printf CMDFILE "set output \n";
  printf CMDFILE "quit \n";
  close(CMDFILE) ;
  
  $retval = `gnuplot < $cmdfile`;
  printf "retval is ..%s..\n", $retval;
  
  if ($term_options =~ /postscript/) {
    $psfile = $output_file;
    $pngfile = $psfile;
    $pngfile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 -geometry 720x504 $psfile $pngfile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }


exit 0;
