Changeset 31 for trunk/test
 Timestamp:
 Jan 12, 2006, 12:45:03 AM (16 years ago)
 Location:
 trunk/test
 Files:

 1 deleted
 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test/gnuplot_pipe.cc
r27 r31 1 1 // $Id$ 2 2 3 #include " gnuplot_i.h"3 #include "Gnuplot.h" 4 4 5 #include <string> 6 #include <iostream> 5 #include <vector> 7 6 8 7 int main(const int argc,const char* argv[]) … … 12 11 bool ok = true; 13 12 14 // Jari speaks out: My first thought was to use one pipe to produce15 // all plots. The idea was to avoid creating pipes since these are16 // expensive. However, the Gnuplot class will run out of resources17 // when a lot of data is to be plotted using plot_x() and18 // plot_xy(). The current limit is 64 plots (plot_equation() and19 // plot_slope() does not add to this count). Well, if all this is20 // jibberish for you, never mind  we are going to write our own21 // Gnuplot pipe using Guha's implementation as inspiration.22 23 // Until the new implementation, use the last example below (look24 // 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 31 13 std::vector<double> x,y; 32 14 for (int i=10; i<=10; ++i) { … … 34 16 y.push_back(i*i); 35 17 } 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' has39 // already been issued. See pngs for examples.40 gnuplot.plot_x(x,"x"); // Jari, shouldn't this be called plot_y?41 18 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"); 47 22 23 svnstat::Gnuplot gnuplot2; 24 gnuplot2.command("set output 'test2.png'; set term png"); 25 gnuplot2.plot_y(x); 48 26 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); 55 31 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); 63 36 64 37 // Jari, if we want to avoid the above usage of plot_x and plot_xy, … … 67 40 // plot_x and plot_xy). Note, the below example compiles, but will 68 41 // fail at run time if 'filename.data' does not, miraculously, exist. 69 Gnuplot gnuplot4;70 gnuplot4.c md("set output 'test6.png'\nset term png");71 gnuplot4.c md("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"); 72 45 73 46 return (ok ? 0 : 1);
Note: See TracChangeset
for help on using the changeset viewer.