Changeset 31 for trunk/test


Ignore:
Timestamp:
Jan 12, 2006, 12:45:03 AM (16 years ago)
Author:
Jari Häkkinen
Message:

Reimplemented the gnuplot pipe implementation.

Location:
trunk/test
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/gnuplot_pipe.cc

    r27 r31  
    11// $Id$
    22
    3 #include "gnuplot_i.h"
     3#include "Gnuplot.h"
    44
    5 #include <string>
    6 #include <iostream>
     5#include <vector>
    76
    87int main(const int argc,const char* argv[])
     
    1211  bool ok = true;
    1312
    14   // Jari speaks out: My first thought was to use one pipe to produce
    15   // all plots. The idea was to avoid creating pipes since these are
    16   // expensive. However, the Gnuplot class will run out of resources
    17   // when a lot of data is to be plotted using plot_x() and
    18   // plot_xy(). The current limit is 64 plots (plot_equation() and
    19   // plot_slope() does not add to this count). Well, if all this is
    20   // jibberish for you, never mind - we are going to write our own
    21   // Gnuplot pipe using Guha's implementation as inspiration.
    22 
    23   // Until the new implementation, use the last example below (look
    24   // for 'Peter, look here') as a template for now.
    25 
    26   Gnuplot gnuplot("steps");
    27   std::string command("set output 'test.png'\nset term png");
    28   gnuplot.cmd(command.c_str());
    29   gnuplot.plot_equation("sin(x)","sine of x");
    30 
    3113  std::vector<double> x,y;
    3214  for (int i=-10; i<=10; ++i) {
     
    3416    y.push_back(i*i);
    3517  }
    36   command=std::string("set output 'test2.png'");
    37   gnuplot.cmd(command.c_str());
    38   // Jari, the next line actually does a 'replot' if a 'plot' has
    39   // already been issued. See pngs for examples.
    40   gnuplot.plot_x(x,"x");  // Jari, shouldn't this be called plot_y?
    4118
    42   command=std::string("set output 'test3.png'");
    43   gnuplot.cmd(command.c_str());
    44   // Jari, the next line actually does a 'replot' if a 'plot' has
    45   // already been issued. See pngs for examples.
    46   gnuplot.plot_xy(x,y,"xy");
     19  svnstat::Gnuplot gnuplot1;
     20  gnuplot1.command("set output 'test1.png'; set term png ; set title 'sine'");
     21  gnuplot1.command("plot sin(x) title 'sine of x' with lines");
    4722
     23  svnstat::Gnuplot gnuplot2;
     24  gnuplot2.command("set output 'test2.png'; set term png");
     25  gnuplot2.plot_y(x);
    4826
    49   // Peter, look here.
    50   // Jari, Maybe we should stick to this type of stuff until the new
    51   // implementation.
    52   Gnuplot gnuplot1;
    53   gnuplot1.cmd("set output 'test4.png'\nset term png");
    54   gnuplot1.cmd("plot sin(x) title 'sine of x' with lines");
     27  svnstat::Gnuplot gnuplot3;
     28  gnuplot3.command("set output 'test3.png'; set term png");
     29  gnuplot3.linetitle("parabola");
     30  gnuplot3.plot_xy(x,y);
    5531
    56   Gnuplot gnuplot2;
    57   gnuplot2.cmd("set output 'test5.png'\nset term png");
    58   gnuplot2.plot_x(x,"x"); // Jari, shouldn't this be called plot_y?
    59 
    60   Gnuplot gnuplot3;
    61   gnuplot3.cmd("set output 'test6.png'\nset term png");
    62   gnuplot3.plot_xy(x,y,"xy");
     32  gnuplot3.command("set output 'test4.png'; set title 'composite'");
     33  gnuplot3.linestyle("linespoints");
     34  gnuplot3.linetitle("");
     35  gnuplot3.plot_y(x,true);
    6336
    6437  // Jari, if we want to avoid the above usage of plot_x and plot_xy,
     
    6740  // plot_x and plot_xy). Note, the below example compiles, but will
    6841  // fail at run time if 'filename.data' does not, miraculously, exist.
    69   Gnuplot gnuplot4;
    70   gnuplot4.cmd("set output 'test6.png'\nset term png");
    71   gnuplot4.cmd("plot 'filename.data' using 1:2 with linespoints");
     42  svnstat::Gnuplot gnuplot4;
     43  gnuplot4.command("set output 'test5.png'\nset term png");
     44  gnuplot4.command("plot 'filename.data' using 1:2 with linespoints");
    7245
    7346  return (ok ? 0 : -1);
Note: See TracChangeset for help on using the changeset viewer.