#!/usr/bin/perl
#
# Plots for (bulk) properties of discovered planets
# 
# MWR 9/28/2016

if (1 == 1) {
    
      ####################################################################
      #  planet mass vs. period, 
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_mass_period_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Orbital Period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet Mass (Jupiter units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";

      printf CMDFILE "set label 1 'Transit' at 70000,0.10 font 'Helvetica-Bold,18' textcolor lt 1 \n";
      printf CMDFILE "set label 2 'Radial Vel' at 70000,0.05 font 'Helvetica-Bold,18' textcolor lt 2 \n";
      printf CMDFILE "set label 3 'Imaging' at 70000,0.025 font 'Helvetica-Bold,18' textcolor lt 3 \n";
      printf CMDFILE "set label 4 'Microlens' at 70000,0.0125 font 'Helvetica-Bold,18' textcolor lt 4 \n";
      printf CMDFILE "set label 5 'Timing' at 70000,0.00625 font 'Helvetica-Bold,18' textcolor lt 9 \n";
      printf CMDFILE "set label 7 'Modulation' at 70000,0.003125 font 'Helvetica-Bold,18' textcolor lt 7 \n";
      printf CMDFILE "set label 8 'Pulsar' at 70000,0.00157 font 'Helvetica-Bold,18' textcolor lt 8 \n";
      printf CMDFILE "set label 9 'Eclipse Timing' at 70000,0.00076 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      printf CMDFILE "set label 10 'Pulsation Timing' at 70000,0.00034 font 'Helvetica-Bold,18' textcolor lt 10 \n";
      printf CMDFILE "set label 11 'Nov 27, 2018' at 80000,0.00015 font 'Helvetica-Bold,14' textcolor lt -1 \n";
      
      $cmd = "plot [0.1:1e6][1e-5:100] ";
      $cmd .= " './planet_table.transit.csv' using 7:23 ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv' using 7:23 ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 2 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using 7:23 ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlensing.csv' using 7:23 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.ttv.csv' using 7:23 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.orbital.csv' using 7:23 ";
      $cmd .= "    with points pt 3 ps 0.8 lw 2 lt 1 lc 7 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv' using 7:23 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.eclipse.csv' using 7:23 ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsation.csv' using 7:23 ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 6 ";
      $cmd .= "    t '' ";


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


    
      ####################################################################
      #  planet radius vs. period, 
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_radius_period_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Orbital Period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet Radius (Earth units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key bot right \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0.1:1e6][0.2:0.4e2] ";
      $cmd .= " './planet_table.transit.csv' using 7:(\$28/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv' using 7:(\$28/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.8 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using 7:(\$28/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlensing.csv' using 7:(\$28/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.ttv.csv' using 7:(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.orbital.csv' using 7:(\$28/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv' using 7:(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.eclipse.csv' using 7:(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Eclipse Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsation.csv' using 7:(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 6 ";
      $cmd .= "    t 'Pulsation Timing' ";


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

    
      ####################################################################
      #  planet radius vs. mass, 
      #    with colors denoting discovery method
      #    this is "small" planets only
      #
      # get the arguments
      $output_file = "./planets_radius_mass_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet Mass (Earth masses) ' \n";
      printf CMDFILE "set ylabel 'Planet Radius (Earth radii)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "unset logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key top left \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0.1:100][0:15] ";
      $cmd .= " './planet_table.transit.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.8 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlensing.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.ttv.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.orbital.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.eclipse.csv' using (\$22/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsation.csv' using (\$22/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 6 ";
      $cmd .= "    t '' ";

      $cmd .= " , ";
      # and now some models
      #   this is average density = Earth's average density
#      $cmd .= "    (((3.0*x)/(4.0*3.14159*0.2387))**0.3333) ";
#      $cmd .= "         with lines lt 2 lc -1 t 'Earth density' \n";
#      $cmd .= " , ";
      #   this is average density = water
      $cmd .= "    (((3.0*x)/(4.0*3.14159*0.0432))**0.3333) ";
      $cmd .= "         with lines lt 2 lw 2 lc -1 t 'uniform water' ";
      $cmd .= " , ";
      #   this is average density = Earth's average density
      $cmd .= "    (((3.0*x)/(4.0*3.14159*0.3403))**0.3333) ";
      $cmd .= "         with lines lt 1 lw 2 lc 3 t 'uniform iron' ";

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


    
      ####################################################################
      #  planet radius vs. mass, 
      #    with colors denoting discovery method
      #    this is all planets, big and small
      #
      # get the arguments
      $output_file = "./planets_radius_mass_b.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet Mass (Earth masses) ' \n";
      printf CMDFILE "set ylabel 'Planet Radius (Earth radii)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "unset logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key top left \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0.1:1e4][0:40] ";
      $cmd .= " './planet_table.transit.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.8 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlensing.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.ttv.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.orbital.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv' using (\$23/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.eclipse.csv' using (\$22/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsation.csv' using (\$22/0.0032):(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 6 ";
      $cmd .= "    t '' ";

      $cmd .= " , ";
      # and now some models
      #   this is average density = Earth's average density
#      $cmd .= "    (((3.0*x)/(4.0*3.14159*0.2387))**0.3333) ";
#      $cmd .= "         with lines lt 2 lc -1 t 'Earth density' \n";
#      $cmd .= " , ";
      #   this is average density = water
      $cmd .= "    (((3.0*x)/(4.0*3.14159*0.0432))**0.3333) ";
      $cmd .= "         with lines lt 2 lw 2 lc -1 t 'uniform water' ";
      $cmd .= " , ";
      #   this is average density = Earth's average density
      $cmd .= "    (((3.0*x)/(4.0*3.14159*0.3403))**0.3333) ";
      $cmd .= "         with lines lt 1 lw 2 lc 3 t 'uniform iron' ";

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


    
      ####################################################################
      #  planet eccentricity vs. period, 
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_eccen_period_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet orbital period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet orbital eccentricity' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "unset logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key top left \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0.1:1e5][-0.05:1.1] ";
      $cmd .= " './planet_table.transit.csv' using 7:15 ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv' using 7:15 ";
      $cmd .= "    with points pt 6 ps 0.6 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using 7:15 ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlensing.csv' using 7:15 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.ttv.csv' using 7:15 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.orbital.csv' using 7:15 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.eclipse.csv' using 7:15  ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Eclipse Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsation.csv' using 7:15  ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 10";
      $cmd .= "    t 'Pulsation Timing' ";


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


    
      ####################################################################
      #  planet equlib. temp vs. period, 
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_temp_period_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet orbital period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet equilib. blackbody temp (K)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key bot left  \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
#      $cmd = "plot [0.1:1e5][40:3000] ";
      $cmd = "plot [0.1:1e7][30:5000] ";
      $cmd .= " './planet_table.transit.csv' using 7:89 ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv' using 7:89 ";
      $cmd .= "    with points pt 6 ps 0.6 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using 7:89 ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlensing.csv' using 7:89 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.ttv.csv' using 7:89 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.orbital.csv' using 7:89 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv' using 7:89 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.eclipse.csv' using 7:89  ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Eclipse Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsation.csv' using 7:89  ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 10";
      $cmd .= "    t 'Pulsation Timing' ";


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

    
      ####################################################################
      #  planet irradiation. temp vs. period, 
      #    using my attempt to compute irradiation in earth units
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_temp_period_b.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet orbital period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet irradiation (Earth units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key bot left  \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0.05:1e5][] ";
      $cmd .= " './planet_table.transit.csv' ";
      $cmd .= "    using 7:(((\$63**2.0)*((\$55/5777.0)**4.0))*((1.0/\$11)**2))";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv'  ";
      $cmd .= "    using 7:(((\$63**2.0)*((\$55/5777.0)**4.0))*((1.0/\$11)**2))";
      $cmd .= "    with points pt 6 ps 0.6 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv'  ";
      $cmd .= "    using 7:(((\$63**2.0)*((\$55/5777.0)**4.0))*((1.0/\$11)**2))";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlensing.csv'  ";
      $cmd .= "    using 7:(((\$63**2.0)*((\$55/5777.0)**4.0))*((1.0/\$11)**2))";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.ttv.csv'  ";
      $cmd .= "    using 7:(((\$63**2.0)*((\$55/5777.0)**4.0))*((1.0/\$11)**2))";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.orbital.csv'  ";
      $cmd .= "    using 7:(((\$63**2.0)*((\$55/5777.0)**4.0))*((1.0/\$11)**2))";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv'  ";
      $cmd .= "    using 7:(((\$63**2.0)*((\$55/5777.0)**4.0))*((1.0/\$11)**2))";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.eclipse.csv' using 7:(((\$63**2.0)*((\$55/5777.0)**4.0))*((1.0/\$11)**2))  ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Eclipse Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsation.csv' using 7:(((\$63**2.0)*((\$55/5777.0)**4.0))*((1.0/\$11)**2))  ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 10";
      $cmd .= "    t 'Pulsation Timing' ";


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


    
      ####################################################################
      #  planet radius vs transit depth 
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_radius_depth.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet transit depth (percent) ' \n";
      printf CMDFILE "set ylabel 'Planet radius (Earth units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key top left  \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [1e-3:5][0.2:50] ";
      $cmd .= " './planet_table.transit.csv' ";
      $cmd .= "    using 125:(\$28/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv'  ";
      $cmd .= "    using 125:(\$28/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.6 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv'  ";
      $cmd .= "    using 125:(\$28/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlensing.csv'  ";
      $cmd .= "    using 125:(\$28/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.ttv.csv'  ";
      $cmd .= "    using 125:(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.orbital.csv'  ";
      $cmd .= "    using 125:(\$28/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv'  ";
      $cmd .= "    using 125:(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.eclipse.csv' using 125:(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Eclipse Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsation.csv' using 125:(\$28/0.0911) ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 10";
      $cmd .= "    t 'Pulsation Timing' ";


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


    
      ####################################################################
      #  planet semi-major axis vs orbital period
      #    with colors denoting discovery method
      #    This has NO lines showing p^2 = a^3
      #
      # get the arguments
      $output_file = "./planets_semia_period_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet orbital period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet orbital radius (AU)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "unset logscale y  \n";
      printf CMDFILE "unset logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key top left \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0:4000][0:6.5] ";
      $cmd .= " './planet_table.transit.csv' ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 6 ps 0.6 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlensing.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.ttv.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.orbital.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.eclipse.csv' using 7:11 ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Eclipse Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsation.csv' using 7:11 ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 10";
      $cmd .= "    t 'Pulsation Timing' ";


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

    
      ####################################################################
      #  planet semi-major axis vs orbital period
      #    with colors denoting discovery method
      #    This version has P^2 = a^3 for mass of star = 1 solar mass only
      #
      # get the arguments
      $output_file = "./planets_semia_period_b.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse spacing 1.2 \n";
      printf CMDFILE "set xlabel 'Planet orbital period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet orbital radius (AU)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "unset logscale y  \n";
      printf CMDFILE "unset logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key top left \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0:4000][0:6.5] ";
      $cmd .= " './planet_table.transit.csv' ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 6 ps 0.6 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlensing.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.ttv.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.orbital.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.eclipse.csv' using 7:11 ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Eclipse Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsation.csv' using 7:11 ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 10";
      $cmd .= "    t 'Pulsation Timing' ";
      #  and now one model, for a star of 1 solar mass
      $cmd .= " , ";
      $cmd .= "    (((x/365.25))**0.6666) with lines ";
      $cmd .= "        lt 1 lw 2 lc -1 t 'P^2 = a^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;
    $giffile = $psfile;
    $giffile =~ s/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    
      ####################################################################
      #  planet semi-major axis vs orbital period
      #    with colors denoting discovery method
      #    This has lines showing models for 0.33, 1.0, 3.0 solar masses
      #
      # get the arguments
      $output_file = "./planets_semia_period_c.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet orbital period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet orbital radius (AU)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "unset logscale y  \n";
      printf CMDFILE "unset logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key top left \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0:4000][0:6.5] ";
      $cmd .= " './planet_table.transit.csv' ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 6 ps 0.6 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlensing.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.ttv.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.orbital.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv'  ";
      $cmd .= "    using 7:11 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.eclipse.csv' using 7:11 ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Eclipse Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsation.csv' using 7:11 ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 10";
      $cmd .= "    t 'Pulsation Timing' ";
      #  and now some models, for stars of different masses
      $cmd .= " , ";
      $cmd .= "    (((x/365.25)**0.6666)*(3**0.3333)) with lines ";
      $cmd .= "        lt 2 lw 2 lc 3 t '3 M_{{/=12 O}&{/*-.49 O}{/=12 \\267}}' ";
      $cmd .= " , ";
      $cmd .= "    (((x/365.25))**0.6666) with lines ";
      $cmd .= "        lt 1 lw 2 lc -1 t '1 M_{{/=12 O}&{/*-.49 O}{/=12 \\267}}' ";
      $cmd .= " , ";
      $cmd .= "    (((x/365.25)**0.6666)*((0.33)**0.3333)) with lines ";
      $cmd .= "        lt 3 lw 4 lc 4 t '0.33 M_{{/=12 O}&{/*-.49 O}{/=12 \\267}}' ";


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


}



exit 0;

if (0 == 1) {

      ####################################################################
      #  planet mass vs. separation, 
      #    highlighting microlensing discoveries
      #
      # get the arguments
      $output_file = "./planets_microlensing_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Semi-major axis or separation (AU) ' \n";
      printf CMDFILE "set ylabel 'Planet Mass (Jupiter units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";

      
      $cmd = "plot [0.01:5e2][0.001:40] ";
      $cmd .= " './planet_table.csv' using 10:22 ";
      $cmd .= "    with points pt 6 ps 0.2 lw 6 lt 1 lc -1 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlensing.csv' using 10:22 ";
      $cmd .= "    with points pt 6 ps 1.5 lw 6 lt 1 lc 1 ";
      $cmd .= "    t '' ";

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


      ####################################################################
      #  planet mass vs. separation, 
      #    highlighting imaging discoveries
      #
      # get the arguments
      $output_file = "./planets_imaging_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Semi-major axis or separation (AU) ' \n";
      printf CMDFILE "set ylabel 'Planet Mass (Jupiter units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";

      
      $cmd = "plot [0.01:1e3][0.001:50] ";
      $cmd .= " './planet_table.csv' using 10:22 ";
      $cmd .= "    with points pt 6 ps 0.2 lw 6 lt 1 lc -1 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using 10:22 ";
      $cmd .= "    with points pt 4 ps 1.5 lw 6 lt 1 lc 2 ";
      $cmd .= "    t '' ";

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


      ####################################################################
      #  planet mass vs. ANGULAR separation, 
      #    highlighting (or only?) imaging discoveries
      #
      # get the arguments
      $output_file = "./planets_imaging_b.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Angular separation (arcsec) ' \n";
      printf CMDFILE "set ylabel 'Planet Mass (Jupiter units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";

      
      $cmd = "plot [][0.001:50] ";
      $cmd .= " './planet_table.csv' using (\$10/\$43):22 ";
      $cmd .= "    with points pt 6 ps 0.2 lw 6 lt 1 lc -1 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using (\$10/\$43):22 ";
      $cmd .= "    with points pt 4 ps 1.5 lw 6 lt 1 lc 2 ";
      $cmd .= "    t '' ";

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



      ####################################################################
      #  planet mass vs. ANGULAR separation, 
      #    highlighting (or only?) imaging discoveries
      #    This time in linear units, focus on interesting region
      #
      # get the arguments
      $output_file = "./planets_imaging_c.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Angular separation (arcsec) ' \n";
      printf CMDFILE "set ylabel 'Planet Mass (Jupiter units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";

      
      $cmd = "plot [0.02:10][0.001:50] ";
      $cmd .= " './planet_table.csv' using (\$10/\$43):22 ";
      $cmd .= "    with points pt 6 ps 0.2 lw 6 lt 1 lc -1 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using (\$10/\$43):22 ";
      $cmd .= "    with points pt 4 ps 1.5 lw 6 lt 1 lc 2 ";
      $cmd .= "    t '' ";

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

}



      ####################################################################
      #  planet radius vs. orbital radius for Kepler planets
      #    before and after 2013
      #
      # get the arguments
      $output_file = "./planets_kepler_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Orbital period (years) ' \n";
      printf CMDFILE "set ylabel 'Planet Radius (Jupiter units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";

      
      $cmd = "plot [0.02:10][0.001:50] ";
      $cmd .= " './planet_table.csv' using (\$10/\$43):22 ";
      $cmd .= "    with points pt 6 ps 0.2 lw 6 lt 1 lc -1 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using (\$10/\$43):22 ";
      $cmd .= "    with points pt 4 ps 1.5 lw 6 lt 1 lc 2 ";
      $cmd .= "    t '' ";

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






exit 0;
