src/GamIO/Ggnuplot.cc
/* These routines are intended to output data files in ASCII format which are
   readable by the public domain program Gnuplot.  Their purpose is to provide
   a simple means to view GAMMA generated contour plots. Note that Gnuplot
   takes ASCII files filled with {x,y,z} points as input for 3D plots.  Only 
   one point per ASCII file line is allowed, the three ordinates separated by 	
   spaces. The x & y ordinates are optional but are output in these routines.
   For contour plots, the output ASCII file must have a blank line following 	
   each row.  Also, the points must be "gridded", meaning that all points of
   the 2D data set must be present (no skipping allowed as in the stack plots).	
   The plots themselves will be displayed as		
  									
  			[-x, +x] from left to right			
  			[-y, +y] from front to back			
  			[-z, +z] from top to bottom			
  									
   Useful gnuplot commands for stack plots are		
  									
  			set parametric       (independent rows)		
  			set data style lines (connected points)		
  			splot "filename"     (draw stack plot)               */
These routines are intended to output data files in ASCII format which are
readable by the public domain program Gnuplot.  Their purpose is to provide
a simple means to view GAMMA generated contour plots. Note that Gnuplot
takes ASCII files filled with {x,y,z} points as input for 3D plots.  Only
one point per ASCII file line is allowed, the three ordinates separated by
spaces. The x & y ordinates are optional but are output in these routines.
For contour plots, the output ASCII file must have a blank line following
each row.  Also, the points must be "gridded", meaning that all points of
the 2D data set must be present (no skipping allowed as in the stack plots).
The plots themselves will be displayed as

[-x, +x] from left to right
[-y, +y] from front to back
[-z, +z] from top to bottom

Useful gnuplot commands for stack plots are

set parametric       (independent rows)
set data style lines (connected points)
splot "filename"     (draw stack plot)
These routines are intended to output data files in ASCII format which are readable by the public domain program Gnuplot . Their purpose is to provide a simple means to view GAMMA generated contour plots . Note that Gnuplot takes ASCII files filled with { x y z } points as input for 3D plots . Only one point per ASCII file line is allowed the three ordinates separated by spaces . The x & y ordinates are optional but are output in these routines . For contour plots the output ASCII file must have a blank line following each row . Also the points must be " gridded " meaning that all points of the 2D data set must be present ( no skipping allowed as in the stack plots ) . The plots themselves will be displayed as [ - x + x ] from left to right [ - y + y ] from front to back [ - z + z ] from top to bottom Useful gnuplot commands for stack plots are set parametric ( independent rows ) set data style lines ( connected points ) splot " filename " ( draw stack plot )
void GP_contour(std::ofstream& ofstr, const row_vector &vx, double row,
                              int ri, double xmin, double xmax, double cutoff)
  {
  int np = vx.size();				
  int i = 0;					
  int ptaxis = 0;				
  double delx = 0;				
  if(xmin != xmax)				
    {						
    ptaxis = 1;					
    delx = (xmax-xmin)/double(np-1);
    }
  double pt;					
  double ymax=HUGE_VAL,ymin=HUGE_VAL;			
  if(ptaxis && !cutoff)				
    {						
    if(ri >= 0)					
      {
      pt = Re(vx.get(i));
      if(ymax < pt) ymax = pt;
      if(ymin > pt) ymin = pt;
      }
    if(ri)					
      {
      pt = Im(vx.get(i));
      if(ymax < pt) ymax = pt;
      if(ymin > pt) ymin = pt;
      }
    }
  if(!cutoff) cutoff = 1.e-3*(ymax-ymin);	
  if(ri >= 0)                                   
    for(i=0; i<np; i++)				
      {
      if(ptaxis)				
        {
        pt = Re(vx.get(i));			
        ofstr<<xmin+double(i)*delx << "  "	
              << row << " " 			
              << pt << "\n";			
        }
      else					
        {					
        ofstr << Gdec(i) << " " 			
              << row << " " 			
              << vx.getRe(i) << "\n";
        }
      }
  if(ri > 0)                                    
      ofstr << "\n";				
  if(ri)                                        
    for(i=0; i<np; i++)
      {
      if(ptaxis)
        {
        pt = vx.getIm(i);
        ofstr << xmin + double(i)*delx << "  "
              << row << " " 
              << pt << "\n";
        }
      else
        {
        ofstr << Gdec(i) << " " 
              << row << " " 
              << vx.getIm(i) << "\n";
        }
      }
  ofstr << "\n";			
  }
void GP_contour ( std :: ofstream & ofstr , const row_vector & vx , double row , int ri , double xmin , double xmax , double cutoff ) { int np = vx . size ( ) ; int i = 0 ; int ptaxis = 0 ; double delx = 0 ; if ( xmin != xmax ) { ptaxis = 1 ; delx = ( xmax - xmin ) / double ( np - 1 ) ; } double pt ; double ymax = HUGE_VAL , ymin = HUGE_VAL ; if ( ptaxis && ! cutoff ) { if ( ri >= 0 ) { pt = Re ( vx . get ( i ) ) ; if ( ymax < pt ) ymax = pt ; if ( ymin > pt ) ymin = pt ; } if ( ri ) { pt = Im ( vx . get ( i ) ) ; if ( ymax < pt ) ymax = pt ; if ( ymin > pt ) ymin = pt ; } } if ( ! cutoff ) cutoff = 1.e-3 * ( ymax - ymin ) ; if ( ri >= 0 ) for ( i = 0 ; i < np ; i ++ ) { if ( ptaxis ) { pt = Re ( vx . get ( i ) ) ; ofstr << xmin + double ( i ) * delx << " " << row << " " << pt << " \n " ; } else { ofstr << Gdec ( i ) << " " << row << " " << vx . getRe ( i ) << " \n " ; } } if ( ri > 0 ) ofstr << " \n " ; if ( ri ) for ( i = 0 ; i < np ; i ++ ) { if ( ptaxis ) { pt = vx . getIm ( i ) ; ofstr << xmin + double ( i ) * delx << " " << row << " " << pt << " \n " ; } else { ofstr << Gdec ( i ) << " " << row << " " << vx . getIm ( i ) << " \n " ; } } ofstr << " \n " ; }
These routines are intended to output data files in ASCII format which are
readable by the public domain program Gnuplot.
These routines are intended to output data files in ASCII format which are readable by the public domain program Gnuplot .
// Input	ofstr     : Output filestream // 		vx        : Data vector //		row       : Row value or y-axis value //		ri	  : Flag for real versus imaginary plot //			    ri = 0  : reals only //			    ri = <0 : imaginaries only //			    ri = >0 : both  //              xmin      : Plot horizontal (x=0) point value //              xmax      : Plot horizontal (x=end) point value //		cutoff    : Data cutoff (where to set zero) // Return		  : Void, the information in vector vx is //			    output to ofstr in ASCII format suitable //			    for use in gnuplot.  Each data point is //			    written as {x,y,z} where x is the point //			    number, y the row number, and z the vector //			    point value  // Note			  : This is essentially the same function as //			    GP_stack except that all points are output //    (xmin,row,vx(0))  (xmin+delx,row,vx(1))  ......... (xmax,row,vx(np-1)) // Number of points in vector // Vector point count // Assume x ordinates not output // If they are to be output, // then set the ptaxis flag // & figure out what the x-axis // increment is // Set up for data reduction // (done if ordinates output) // If ordinates output, find max & min // if no cutoff is set for compression // Search the real points // Search the imaginary points // Cutoff for data reduction (resolution) // Write data for real plot //	Loop over all the points //	This if an x-axis is important //	This is the point (intensity) //	First output the x axis value //	Now output the y axis value //	Now output the intensity value // 	This if just y axis used (default) //	Must plot all points this way //	because x values assumed evenly  //	incremented // Blank line to separate plots // if both real and imaginaries output // Write data for imaginary plot // Another empty line, assume