#!/usr/bin/perl
#

  my($output_file, $term_options);


  # First, we print just the ellipse 
  $output_file = "ellipse_focus_a.ps";
  $term_options = "postscript enhanced color '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 size square \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set nokey \n";
  printf CMDFILE "set ylabel '' \n";
  printf CMDFILE "set xlabel '' \n";
  printf CMDFILE "set title 'Ellipse parameters '\n";

  $cmd = "plot [-1.1:1.1][-1.1:1.1] 'compare_ellipse_easy.out' using 1:4 ";
  $cmd .= "  with lines lt 1 lc 1 lw 3 ";
  $cmd .= " , ";
  $cmd .= "                         'compare_ellipse_easy.out' using 1:5 ";
  $cmd .= "  with lines lt 1 lc 1 lw 3 ";
  $cmd .= " , ";
  $cmd .= "                         'compare_ellipse_easy_foc.dat' using 1:2 ";
  $cmd .= "  with points pt 6 ps 1.5 lt 1 lc 3 lw 6 ";
  $cmd .= " , ";

  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;
    $giffile = $psfile;
    $giffile =~ s/.ps$/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }


exit 0;

