#include <gnuplot_i.hpp>
Public Member Functions | |
Gnuplot (const std::string &style="points") | |
set a style during construction | |
Gnuplot (const std::vector< double > &x, const std::string &title="", const std::string &style="points", const std::string &labelx="x", const std::string &labely="y") | |
plot a single std::vector at one go | |
Gnuplot (const std::vector< double > &x, const std::vector< double > &y, const std::string &title="", const std::string &style="points", const std::string &labelx="x", const std::string &labely="y") | |
plot pairs std::vector at one go | |
Gnuplot (const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, const std::string &title="", const std::string &style="points", const std::string &labelx="x", const std::string &labely="y", const std::string &labelz="z") | |
plot triples std::vector at one go | |
~Gnuplot () | |
destructor: needed to delete temporary files | |
Gnuplot & | cmd (const std::string &cmdstr) |
send a command to gnuplot | |
Gnuplot & | operator<< (const std::string &cmdstr) |
Sends a command to an active gnuplot session, identical to cmd() send a command to gnuplot using the << operator. | |
Gnuplot & | showonscreen () |
sets terminal type to terminal_std | |
Gnuplot & | savetops (const std::string &filename="gnuplot_output") |
saves a gnuplot session to a postscript file, filename without extension | |
Gnuplot & | set_style (const std::string &stylestr="points") |
Gnuplot & | set_smooth (const std::string &stylestr="csplines") |
Gnuplot & | unset_smooth () |
unset smooth attention: smooth is not set by default | |
Gnuplot & | set_pointsize (const double pointsize=1.0) |
scales the size of the points used in plots | |
Gnuplot & | set_grid () |
turns grid on/off | |
Gnuplot & | unset_grid () |
grid is not set by default | |
Gnuplot & | set_multiplot () |
Gnuplot & | unset_multiplot () |
Gnuplot & | set_samples (const int samples=100) |
set sampling rate of functions, or for interpolating data | |
Gnuplot & | set_isosamples (const int isolines=10) |
set isoline density (grid) for plotting functions as surfaces (for 3d plots) | |
Gnuplot & | set_hidden3d () |
Gnuplot & | unset_hidden3d () |
Gnuplot & | set_contour (const std::string &position="base") |
Gnuplot & | unset_contour () |
Gnuplot & | set_surface () |
Gnuplot & | unset_surface () |
Gnuplot & | set_legend (const std::string &position="default") |
Gnuplot & | unset_legend () |
Switches legend off attention:legend is set by default. | |
Gnuplot & | set_title (const std::string &title="") |
sets and clears the title of a gnuplot session | |
Gnuplot & | unset_title () |
Clears the title of a gnuplot session The title is not set by default. | |
Gnuplot & | set_ylabel (const std::string &label="x") |
set x axis label | |
Gnuplot & | set_xlabel (const std::string &label="y") |
set y axis label | |
Gnuplot & | set_zlabel (const std::string &label="z") |
set z axis label | |
Gnuplot & | set_xrange (const double iFrom, const double iTo) |
set axis - ranges | |
Gnuplot & | set_yrange (const double iFrom, const double iTo) |
set y-axis - ranges | |
Gnuplot & | set_zrange (const double iFrom, const double iTo) |
set z-axis - ranges | |
Gnuplot & | set_xautoscale () |
Gnuplot & | set_yautoscale () |
Gnuplot & | set_zautoscale () |
Gnuplot & | set_xlogscale (const double base=10) |
turns on/off log scaling for the specified xaxis (logscale is not set by default) | |
Gnuplot & | set_ylogscale (const double base=10) |
turns on/off log scaling for the specified yaxis (logscale is not set by default) | |
Gnuplot & | set_zlogscale (const double base=10) |
turns on/off log scaling for the specified zaxis (logscale is not set by default) | |
Gnuplot & | unset_xlogscale () |
Gnuplot & | unset_ylogscale () |
Gnuplot & | unset_zlogscale () |
Gnuplot & | set_cbrange (const double iFrom, const double iTo) |
set palette range (autoscale by default) | |
Gnuplot & | plotfile_x (const std::string &filename, const unsigned int column=1, const std::string &title="") |
template<typename X > | |
Gnuplot & | plot_x (const X &x, const std::string &title="") |
from std::vector | |
Gnuplot & | plotfile_xy (const std::string &filename, const unsigned int column_x=1, const unsigned int column_y=2, const std::string &title="") |
template<typename X , typename Y > | |
Gnuplot & | plot_xy (const X &x, const Y &y, const std::string &title="") |
from data | |
Gnuplot & | plotfile_xy_err (const std::string &filename, const unsigned int column_x=1, const unsigned int column_y=2, const unsigned int column_dy=3, const std::string &title="") |
template<typename X , typename Y , typename E > | |
Gnuplot & | plot_xy_err (const X &x, const Y &y, const E &dy, const std::string &title="") |
from data | |
Gnuplot & | plotfile_xyz (const std::string &filename, const unsigned int column_x=1, const unsigned int column_y=2, const unsigned int column_z=3, const std::string &title="") |
template<typename X , typename Y , typename Z > | |
Gnuplot & | plot_xyz (const X &x, const Y &y, const Z &z, const std::string &title="") |
from std::vector | |
Gnuplot & | plot_slope (const double a, const double b, const std::string &title="") |
plot an equation of the form: y = ax + b, you supply a and b | |
Gnuplot & | plot_equation (const std::string &equation, const std::string &title="") |
Gnuplot & | plot_equation3d (const std::string &equation, const std::string &title="") |
Gnuplot & | plot_image (const unsigned char *ucPicBuf, const unsigned int iWidth, const unsigned int iHeight, const std::string &title="") |
plot image | |
Gnuplot & | replot (void) |
replot repeats the last plot or splot command. this can be useful for viewing a plot with different set options, or when generating the same plot for several devices (showonscreen, savetops) | |
Gnuplot & | reset_plot () |
resets a gnuplot session (next plot will erase previous ones) | |
Gnuplot & | reset_all () |
resets a gnuplot session and sets all variables to default | |
void | remove_tmpfiles () |
deletes temporary files | |
bool | is_valid () |
Is the gnuplot session valid ?? | |
Static Public Member Functions | |
static bool | set_GNUPlotPath (const std::string &path) |
optional function: set Gnuplot path manual attention: for windows: path with slash '/' not backslash '\' | |
static void | set_terminal_std (const std::string &type) |
Definition at line 68 of file gnuplot_i.hpp.
Gnuplot::Gnuplot | ( | const std::string & | style = "points" |
) | [inline] |
set a style during construction
Definition at line 612 of file gnuplot_i.hpp.
References set_style().
00613 :gnucmd(NULL) ,valid(false) ,two_dim(false) ,nplots(0) 00614 00615 { 00616 init(); 00617 set_style(style); 00618 }
Gnuplot::Gnuplot | ( | const std::vector< double > & | x, | |
const std::string & | title = "" , |
|||
const std::string & | style = "points" , |
|||
const std::string & | labelx = "x" , |
|||
const std::string & | labely = "y" | |||
) | [inline] |
plot a single std::vector at one go
Definition at line 624 of file gnuplot_i.hpp.
References plot_x(), set_style(), set_xlabel(), and set_ylabel().
00629 :gnucmd(NULL) ,valid(false) ,two_dim(false) ,nplots(0) 00630 { 00631 init(); 00632 00633 set_style(style); 00634 set_xlabel(labelx); 00635 set_ylabel(labely); 00636 00637 plot_x(x,title); 00638 }
Gnuplot::Gnuplot | ( | const std::vector< double > & | x, | |
const std::vector< double > & | y, | |||
const std::string & | title = "" , |
|||
const std::string & | style = "points" , |
|||
const std::string & | labelx = "x" , |
|||
const std::string & | labely = "y" | |||
) | [inline] |
plot pairs std::vector at one go
Definition at line 645 of file gnuplot_i.hpp.
References plot_xy(), set_style(), set_xlabel(), and set_ylabel().
00651 :gnucmd(NULL) ,valid(false) ,two_dim(false) ,nplots(0) 00652 { 00653 init(); 00654 00655 set_style(style); 00656 set_xlabel(labelx); 00657 set_ylabel(labely); 00658 00659 plot_xy(x,y,title); 00660 }
Gnuplot::Gnuplot | ( | const std::vector< double > & | x, | |
const std::vector< double > & | y, | |||
const std::vector< double > & | z, | |||
const std::string & | title = "" , |
|||
const std::string & | style = "points" , |
|||
const std::string & | labelx = "x" , |
|||
const std::string & | labely = "y" , |
|||
const std::string & | labelz = "z" | |||
) | [inline] |
plot triples std::vector at one go
Definition at line 667 of file gnuplot_i.hpp.
References plot_xyz(), set_style(), set_xlabel(), set_ylabel(), and set_zlabel().
00675 :gnucmd(NULL) ,valid(false) ,two_dim(false) ,nplots(0) 00676 { 00677 init(); 00678 00679 set_style(style); 00680 set_xlabel(labelx); 00681 set_ylabel(labely); 00682 set_zlabel(labelz); 00683 00684 plot_xyz(x,y,z,title); 00685 }
Gnuplot::~Gnuplot | ( | ) |
destructor: needed to delete temporary files
Definition at line 944 of file gnuplot_i.hpp.
00945 { 00946 // remove_tmpfiles(); 00947 00948 // A stream opened by popen() should be closed by pclose() 00949 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) 00950 if (_pclose(gnucmd) == -1) 00951 #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) 00952 if (pclose(gnucmd) == -1) 00953 #endif 00954 throw GnuplotException("Problem closing communication to gnuplot"); 00955 }
Gnuplot & Gnuplot::cmd | ( | const std::string & | cmdstr | ) |
send a command to gnuplot
Definition at line 1641 of file gnuplot_i.hpp.
Referenced by main(), operator<<(), plot_equation(), plot_equation3d(), plot_image(), plot_slope(), plotfile_x(), plotfile_xy(), plotfile_xy_err(), plotfile_xyz(), replot(), reset_all(), savetops(), set_cbrange(), set_contour(), set_grid(), set_hidden3d(), set_isosamples(), set_legend(), set_multiplot(), set_pointsize(), set_samples(), set_surface(), set_xautoscale(), set_xlabel(), set_xlogscale(), set_xrange(), set_yautoscale(), set_ylabel(), set_ylogscale(), set_yrange(), set_zautoscale(), set_zlabel(), set_zlogscale(), set_zrange(), showonscreen(), unset_contour(), unset_grid(), unset_hidden3d(), unset_legend(), unset_multiplot(), unset_surface(), unset_xlogscale(), unset_ylogscale(), and unset_zlogscale().
01642 { 01643 if( !(valid) ) 01644 { 01645 return *this; 01646 } 01647 01648 01649 // int fputs ( const char * str, FILE * stream ); 01650 // writes the string str to the stream. 01651 // The function begins copying from the address specified (str) until it 01652 // reaches the terminating null character ('\0'). This final 01653 // null-character is not copied to the stream. 01654 fputs( (cmdstr+"\n").c_str(), gnucmd ); 01655 01656 // int fflush ( FILE * stream ); 01657 // If the given stream was open for writing and the last i/o operation was 01658 // an output operation, any unwritten data in the output buffer is written 01659 // to the file. If the argument is a null pointer, all open files are 01660 // flushed. The stream remains open after this call. 01661 fflush(gnucmd); 01662 01663 01664 if( cmdstr.find("replot") != std::string::npos ) 01665 { 01666 return *this; 01667 } 01668 else if( cmdstr.find("splot") != std::string::npos ) 01669 { 01670 two_dim = false; 01671 nplots++; 01672 } 01673 else if( cmdstr.find("plot") != std::string::npos ) 01674 { 01675 two_dim = true; 01676 nplots++; 01677 } 01678 01679 return *this; 01680 }
bool Gnuplot::is_valid | ( | ) | [inline] |
Is the gnuplot session valid ??
--- |
Definition at line 582 of file gnuplot_i.hpp.
Gnuplot& Gnuplot::operator<< | ( | const std::string & | cmdstr | ) | [inline] |
Sends a command to an active gnuplot session, identical to cmd() send a command to gnuplot using the << operator.
cmdstr | --> the command string |
Definition at line 220 of file gnuplot_i.hpp.
References cmd().
00220 { 00221 cmd(cmdstr); 00222 return(*this); 00223 }
Gnuplot & Gnuplot::plot_equation | ( | const std::string & | equation, | |
const std::string & | title = "" | |||
) |
plot an equation supplied as a std::string y=f(x), write only the function f(x) not y= the independent variable has to be x binary operators: ** exponentiation, * multiply, / divide, + add, - substract, % modulo unary operators: - minus, ! factorial elementary functions: rand(x), abs(x), sgn(x), ceil(x), floor(x), int(x), imag(x), real(x), arg(x), sqrt(x), exp(x), log(x), log10(x), sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), atan2(y,x), sinh(x), cosh(x), tanh(x), asinh(x), acosh(x), atanh(x) special functions: erf(x), erfc(x), inverf(x), gamma(x), igamma(a,x), lgamma(x), ibeta(p,q,x), besj0(x), besj1(x), besy0(x), besy1(x), lambertw(x) statistical fuctions: norm(x), invnorm(x)
Definition at line 1345 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01347 { 01348 std::ostringstream cmdstr; 01349 // 01350 // command to be sent to gnuplot 01351 // 01352 if (nplots > 0 && two_dim == true) 01353 cmdstr << "replot "; 01354 else 01355 cmdstr << "plot "; 01356 01357 cmdstr << equation << " title \""; 01358 01359 if (title == "") 01360 cmdstr << "f(x) = " << equation; 01361 else 01362 cmdstr << title; 01363 01364 cmdstr << "\" with " << pstyle; 01365 01366 // 01367 // Do the actual plot 01368 // 01369 cmd(cmdstr.str()); 01370 01371 return *this; 01372 }
Gnuplot & Gnuplot::plot_equation3d | ( | const std::string & | equation, | |
const std::string & | title = "" | |||
) |
plot an equation supplied as a std::string z=f(x,y), write only the function f(x,y) not z= the independent variables have to be x and y
Definition at line 1378 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01380 { 01381 std::ostringstream cmdstr; 01382 // 01383 // command to be sent to gnuplot 01384 // 01385 if (nplots > 0 && two_dim == false) 01386 cmdstr << "replot "; 01387 else 01388 cmdstr << "splot "; 01389 01390 cmdstr << equation << " title \""; 01391 01392 if (title == "") 01393 cmdstr << "f(x,y) = " << equation; 01394 else 01395 cmdstr << title; 01396 01397 cmdstr << "\" with " << pstyle; 01398 01399 // 01400 // Do the actual plot 01401 // 01402 cmd(cmdstr.str()); 01403 01404 return *this; 01405 }
Gnuplot & Gnuplot::plot_image | ( | const unsigned char * | ucPicBuf, | |
const unsigned int | iWidth, | |||
const unsigned int | iHeight, | |||
const std::string & | title = "" | |||
) |
plot image
* note that this function is not valid for versions of GNUPlot below 4.2
Definition at line 1586 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01590 { 01591 std::ofstream tmp; 01592 std::string name = create_tmpfile(tmp); 01593 if (name == "") 01594 return *this; 01595 01596 // 01597 // write the data to file 01598 // 01599 int iIndex = 0; 01600 for(int iRow = 0; iRow < iHeight; iRow++) 01601 { 01602 for(int iColumn = 0; iColumn < iWidth; iColumn++) 01603 { 01604 tmp << iColumn << " " << iRow << " " 01605 << static_cast<float>(ucPicBuf[iIndex++]) << std::endl; 01606 } 01607 } 01608 01609 tmp.flush(); 01610 tmp.close(); 01611 01612 01613 std::ostringstream cmdstr; 01614 // 01615 // command to be sent to gnuplot 01616 // 01617 if (nplots > 0 && two_dim == true) 01618 cmdstr << "replot "; 01619 else 01620 cmdstr << "plot "; 01621 01622 if (title == "") 01623 cmdstr << "\"" << name << "\" with image"; 01624 else 01625 cmdstr << "\"" << name << "\" title \"" << title << "\" with image"; 01626 01627 // 01628 // Do the actual plot 01629 // 01630 cmd(cmdstr.str()); 01631 01632 return *this; 01633 }
Gnuplot & Gnuplot::plot_slope | ( | const double | a, | |
const double | b, | |||
const std::string & | title = "" | |||
) |
plot an equation of the form: y = ax + b, you supply a and b
Definition at line 1311 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01314 { 01315 std::ostringstream cmdstr; 01316 // 01317 // command to be sent to gnuplot 01318 // 01319 if (nplots > 0 && two_dim == true) 01320 cmdstr << "replot "; 01321 else 01322 cmdstr << "plot "; 01323 01324 cmdstr << a << " * x + " << b << " title \""; 01325 01326 if (title == "") 01327 cmdstr << "f(x) = " << a << " * x + " << b; 01328 else 01329 cmdstr << title; 01330 01331 cmdstr << "\" with " << pstyle; 01332 01333 // 01334 // Do the actual plot 01335 // 01336 cmd(cmdstr.str()); 01337 01338 return *this; 01339 }
Gnuplot & Gnuplot::plot_x | ( | const X & | x, | |
const std::string & | title = "" | |||
) | [inline] |
from std::vector
Plots a 2d graph from a list of doubles: x.
Definition at line 693 of file gnuplot_i.hpp.
References plotfile_x().
Referenced by Gnuplot(), and main().
00694 { 00695 if (x.size() == 0) 00696 { 00697 throw GnuplotException("std::vector too small"); 00698 return *this; 00699 } 00700 00701 std::ofstream tmp; 00702 std::string name = create_tmpfile(tmp); 00703 if (name == "") 00704 return *this; 00705 00706 // 00707 // write the data to file 00708 // 00709 for (unsigned int i = 0; i < x.size(); i++) 00710 tmp << x[i] << std::endl; 00711 00712 tmp.flush(); 00713 tmp.close(); 00714 00715 00716 plotfile_x(name, 1, title); 00717 00718 return *this; 00719 }
Gnuplot & Gnuplot::plot_xy | ( | const X & | x, | |
const Y & | y, | |||
const std::string & | title = "" | |||
) | [inline] |
from data
Plots a 2d graph from a list of doubles: x y.
Definition at line 727 of file gnuplot_i.hpp.
References plotfile_xy().
Referenced by Gnuplot(), and main().
00728 { 00729 if (x.size() == 0 || y.size() == 0) 00730 { 00731 throw GnuplotException("std::vectors too small"); 00732 return *this; 00733 } 00734 00735 if (x.size() != y.size()) 00736 { 00737 throw GnuplotException("Length of the std::vectors differs"); 00738 return *this; 00739 } 00740 00741 00742 std::ofstream tmp; 00743 std::string name = create_tmpfile(tmp); 00744 if (name == "") 00745 return *this; 00746 00747 // 00748 // write the data to file 00749 // 00750 for (unsigned int i = 0; i < x.size(); i++) 00751 tmp << x[i] << " " << y[i] << std::endl; 00752 00753 tmp.flush(); 00754 tmp.close(); 00755 00756 00757 plotfile_xy(name, 1, 2, title); 00758 00759 return *this; 00760 }
Gnuplot & Gnuplot::plot_xy_err | ( | const X & | x, | |
const Y & | y, | |||
const E & | dy, | |||
const std::string & | title = "" | |||
) | [inline] |
from data
-----------------------------------------------------------------------------
plot x,y pairs with dy errorbars
Definition at line 767 of file gnuplot_i.hpp.
References plotfile_xy_err().
Referenced by main().
00771 { 00772 if (x.size() == 0 || y.size() == 0 || dy.size() == 0) 00773 { 00774 throw GnuplotException("std::vectors too small"); 00775 return *this; 00776 } 00777 00778 if (x.size() != y.size() || y.size() != dy.size()) 00779 { 00780 throw GnuplotException("Length of the std::vectors differs"); 00781 return *this; 00782 } 00783 00784 00785 std::ofstream tmp; 00786 std::string name = create_tmpfile(tmp); 00787 if (name == "") 00788 return *this; 00789 00790 // 00791 // write the data to file 00792 // 00793 for (unsigned int i = 0; i < x.size(); i++) 00794 tmp << x[i] << " " << y[i] << " " << dy[i] << std::endl; 00795 00796 tmp.flush(); 00797 tmp.close(); 00798 00799 00800 // Do the actual plot 00801 plotfile_xy_err(name, 1, 2, 3, title); 00802 00803 return *this; 00804 }
Gnuplot & Gnuplot::plot_xyz | ( | const X & | x, | |
const Y & | y, | |||
const Z & | z, | |||
const std::string & | title = "" | |||
) | [inline] |
from std::vector
Definition at line 812 of file gnuplot_i.hpp.
References plotfile_xyz().
Referenced by Gnuplot(), and main().
00816 { 00817 if (x.size() == 0 || y.size() == 0 || z.size() == 0) 00818 { 00819 throw GnuplotException("std::vectors too small"); 00820 return *this; 00821 } 00822 00823 if (x.size() != y.size() || x.size() != z.size()) 00824 { 00825 throw GnuplotException("Length of the std::vectors differs"); 00826 return *this; 00827 } 00828 00829 00830 std::ofstream tmp; 00831 std::string name = create_tmpfile(tmp); 00832 if (name == "") 00833 return *this; 00834 00835 // 00836 // write the data to file 00837 // 00838 for (unsigned int i = 0; i < x.size(); i++) 00839 tmp << x[i] << " " << y[i] << " " << z[i] <<std::endl; 00840 00841 tmp.flush(); 00842 tmp.close(); 00843 00844 00845 plotfile_xyz(name, 1, 2, 3, title); 00846 00847 return *this; 00848 }
Gnuplot & Gnuplot::plotfile_x | ( | const std::string & | filename, | |
const unsigned int | column = 1 , |
|||
const std::string & | title = "" | |||
) |
plot a single std::vector: x from file
Definition at line 1412 of file gnuplot_i.hpp.
References cmd().
Referenced by plot_x().
01415 { 01416 // 01417 // check if file exists 01418 // 01419 file_available(filename); 01420 01421 01422 std::ostringstream cmdstr; 01423 // 01424 // command to be sent to gnuplot 01425 // 01426 if (nplots > 0 && two_dim == true) 01427 cmdstr << "replot "; 01428 else 01429 cmdstr << "plot "; 01430 01431 cmdstr << "\"" << filename << "\" using " << column; 01432 01433 if (title == "") 01434 cmdstr << " notitle "; 01435 else 01436 cmdstr << " title \"" << title << "\" "; 01437 01438 if(smooth == "") 01439 cmdstr << "with " << pstyle; 01440 else 01441 cmdstr << "smooth " << smooth; 01442 01443 // 01444 // Do the actual plot 01445 // 01446 cmd(cmdstr.str()); //nplots++; two_dim = true; already in cmd(); 01447 01448 return *this; 01449 }
Gnuplot & Gnuplot::plotfile_xy | ( | const std::string & | filename, | |
const unsigned int | column_x = 1 , |
|||
const unsigned int | column_y = 2 , |
|||
const std::string & | title = "" | |||
) |
plot x,y pairs: x y from file
Definition at line 1457 of file gnuplot_i.hpp.
References cmd().
Referenced by plot_xy().
01461 { 01462 // 01463 // check if file exists 01464 // 01465 file_available(filename); 01466 01467 01468 std::ostringstream cmdstr; 01469 // 01470 // command to be sent to gnuplot 01471 // 01472 if (nplots > 0 && two_dim == true) 01473 cmdstr << "replot "; 01474 else 01475 cmdstr << "plot "; 01476 01477 cmdstr << "\"" << filename << "\" using " << column_x << ":" << column_y; 01478 01479 if (title == "") 01480 cmdstr << " notitle "; 01481 else 01482 cmdstr << " title \"" << title << "\" "; 01483 01484 if(smooth == "") 01485 cmdstr << "with " << pstyle; 01486 else 01487 cmdstr << "smooth " << smooth; 01488 01489 // 01490 // Do the actual plot 01491 // 01492 cmd(cmdstr.str()); 01493 01494 return *this; 01495 }
Gnuplot & Gnuplot::plotfile_xy_err | ( | const std::string & | filename, | |
const unsigned int | column_x = 1 , |
|||
const unsigned int | column_y = 2 , |
|||
const unsigned int | column_dy = 3 , |
|||
const std::string & | title = "" | |||
) |
plot x,y pairs with dy errorbars: x y dy from file
Definition at line 1502 of file gnuplot_i.hpp.
References cmd().
Referenced by plot_xy_err().
01507 { 01508 // 01509 // check if file exists 01510 // 01511 file_available(filename); 01512 01513 std::ostringstream cmdstr; 01514 // 01515 // command to be sent to gnuplot 01516 // 01517 if (nplots > 0 && two_dim == true) 01518 cmdstr << "replot "; 01519 else 01520 cmdstr << "plot "; 01521 01522 cmdstr << "\"" << filename << "\" using " 01523 << column_x << ":" << column_y << ":" << column_dy 01524 << " with errorbars "; 01525 01526 if (title == "") 01527 cmdstr << " notitle "; 01528 else 01529 cmdstr << " title \"" << title << "\" "; 01530 01531 // 01532 // Do the actual plot 01533 // 01534 cmd(cmdstr.str()); 01535 01536 return *this; 01537 }
Gnuplot & Gnuplot::plotfile_xyz | ( | const std::string & | filename, | |
const unsigned int | column_x = 1 , |
|||
const unsigned int | column_y = 2 , |
|||
const unsigned int | column_z = 3 , |
|||
const std::string & | title = "" | |||
) |
plot x,y,z triples: x y z from file
Definition at line 1544 of file gnuplot_i.hpp.
References cmd().
Referenced by plot_xyz().
01549 { 01550 // 01551 // check if file exists 01552 // 01553 file_available(filename); 01554 01555 std::ostringstream cmdstr; 01556 // 01557 // command to be sent to gnuplot 01558 // 01559 if (nplots > 0 && two_dim == false) 01560 cmdstr << "replot "; 01561 else 01562 cmdstr << "splot "; 01563 01564 cmdstr << "\"" << filename << "\" using " << column_x << ":" << column_y 01565 << ":" << column_z; 01566 01567 if (title == "") 01568 cmdstr << " notitle with " << pstyle; 01569 else 01570 cmdstr << " title \"" << title << "\" with " << pstyle; 01571 01572 // 01573 // Do the actual plot 01574 // 01575 cmd(cmdstr.str()); 01576 01577 return *this; 01578 }
void Gnuplot::remove_tmpfiles | ( | ) |
deletes temporary files
Definition at line 1948 of file gnuplot_i.hpp.
01948 { 01949 if ((tmpfile_list).size() > 0) 01950 { 01951 for (unsigned int i = 0; i < tmpfile_list.size(); i++) 01952 remove( tmpfile_list[i].c_str() ); 01953 01954 Gnuplot::tmpfile_num -= tmpfile_list.size(); 01955 } 01956 }
Gnuplot& Gnuplot::replot | ( | void | ) | [inline] |
replot repeats the last plot or splot command. this can be useful for viewing a plot with different set options, or when generating the same plot for several devices (showonscreen, savetops)
--- |
Definition at line 563 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
00563 {if (nplots > 0) cmd("replot");return *this;};
Gnuplot & Gnuplot::reset_all | ( | ) |
resets a gnuplot session and sets all variables to default
Definition at line 976 of file gnuplot_i.hpp.
References cmd(), and showonscreen().
Referenced by main().
00977 { 00978 // remove_tmpfiles(); 00979 00980 nplots = 0; 00981 cmd("reset"); 00982 cmd("clear"); 00983 pstyle = "points"; 00984 smooth = ""; 00985 showonscreen(); 00986 00987 return *this; 00988 }
Gnuplot & Gnuplot::reset_plot | ( | ) |
resets a gnuplot session (next plot will erase previous ones)
Definition at line 962 of file gnuplot_i.hpp.
Referenced by main().
Gnuplot & Gnuplot::savetops | ( | const std::string & | filename = "gnuplot_output" |
) |
saves a gnuplot session to a postscript file, filename without extension
Definition at line 1077 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01078 { 01079 cmd("set terminal postscript color"); 01080 01081 std::ostringstream cmdstr; 01082 cmdstr << "set output \"" << filename << ".ps\""; 01083 cmd(cmdstr.str()); 01084 01085 return *this; 01086 }
Gnuplot & Gnuplot::set_cbrange | ( | const double | iFrom, | |
const double | iTo | |||
) |
set palette range (autoscale by default)
Definition at line 1295 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01297 { 01298 std::ostringstream cmdstr; 01299 01300 cmdstr << "set cbrange[" << iFrom << ":" << iTo << "]"; 01301 cmd(cmdstr.str()); 01302 01303 return *this; 01304 }
Gnuplot & Gnuplot::set_contour | ( | const std::string & | position = "base" |
) |
enables/disables contour drawing for surfaces (for 3d plot) base, surface, both
Definition at line 1190 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01191 { 01192 if (position.find("base") == std::string::npos && 01193 position.find("surface") == std::string::npos && 01194 position.find("both") == std::string::npos ) 01195 { 01196 cmd("set contour base"); 01197 } 01198 else 01199 { 01200 cmd("set contour " + position); 01201 } 01202 01203 return *this; 01204 }
bool Gnuplot::set_GNUPlotPath | ( | const std::string & | path | ) | [static] |
optional function: set Gnuplot path manual attention: for windows: path with slash '/' not backslash '\'
path | --> the gnuplot path |
Definition at line 856 of file gnuplot_i.hpp.
00857 { 00858 00859 std::string tmp = path + "/" + Gnuplot::m_sGNUPlotFileName; 00860 00861 00862 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) 00863 if ( Gnuplot::file_exists(tmp,0) ) // check existence 00864 #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) 00865 if ( Gnuplot::file_exists(tmp,1) ) // check existence and execution permission 00866 #endif 00867 { 00868 Gnuplot::m_sGNUPlotPath = path; 00869 return true; 00870 } 00871 else 00872 { 00873 Gnuplot::m_sGNUPlotPath.clear(); 00874 return false; 00875 } 00876 }
Gnuplot& Gnuplot::set_grid | ( | ) | [inline] |
turns grid on/off
Definition at line 266 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
00266 {cmd("set grid");return *this;};
Gnuplot& Gnuplot::set_hidden3d | ( | ) | [inline] |
enables/disables hidden line removal for surface plotting (for 3d plot)
--- |
Definition at line 302 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
00302 {cmd("set hidden3d");return *this;};
Gnuplot & Gnuplot::set_isosamples | ( | const int | isolines = 10 |
) |
set isoline density (grid) for plotting functions as surfaces (for 3d plots)
Definition at line 1175 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01176 { 01177 std::ostringstream cmdstr; 01178 cmdstr << "set isosamples " << isolines; 01179 cmd(cmdstr.str()); 01180 01181 return *this; 01182 }
Gnuplot & Gnuplot::set_legend | ( | const std::string & | position = "default" |
) |
switches legend on/off position: inside/outside, left/center/right, top/center/bottom, nobox/box
Definition at line 1092 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01093 { 01094 std::ostringstream cmdstr; 01095 cmdstr << "set key " << position; 01096 01097 cmd(cmdstr.str()); 01098 01099 return *this; 01100 }
Gnuplot& Gnuplot::set_multiplot | ( | ) | [inline] |
set the mulitplot mode
--- |
Definition at line 277 of file gnuplot_i.hpp.
References cmd().
00277 {cmd("set multiplot") ;return *this;};
Gnuplot & Gnuplot::set_pointsize | ( | const double | pointsize = 1.0 |
) |
scales the size of the points used in plots
Definition at line 1148 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01149 { 01150 std::ostringstream cmdstr; 01151 cmdstr << "set pointsize " << pointsize; 01152 cmd(cmdstr.str()); 01153 01154 return *this; 01155 }
Gnuplot & Gnuplot::set_samples | ( | const int | samples = 100 |
) |
set sampling rate of functions, or for interpolating data
Definition at line 1161 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01162 { 01163 std::ostringstream cmdstr; 01164 cmdstr << "set samples " << samples; 01165 cmd(cmdstr.str()); 01166 01167 return *this; 01168 }
Gnuplot & Gnuplot::set_smooth | ( | const std::string & | stylestr = "csplines" |
) |
interpolation and approximation of data, arguments: csplines, bezier, acsplines (for data values > 0), sbezier, unique, frequency (works only with plot_x, plot_xy, plotfile_x, plotfile_xy (if smooth is set, set_style has no effekt on data plotting)
Definition at line 1041 of file gnuplot_i.hpp.
Referenced by main().
01042 { 01043 if (stylestr.find("unique") == std::string::npos && 01044 stylestr.find("frequency") == std::string::npos && 01045 stylestr.find("csplines") == std::string::npos && 01046 stylestr.find("acsplines") == std::string::npos && 01047 stylestr.find("bezier") == std::string::npos && 01048 stylestr.find("sbezier") == std::string::npos ) 01049 { 01050 smooth = ""; 01051 } 01052 else 01053 { 01054 smooth = stylestr; 01055 } 01056 01057 return *this; 01058 }
Gnuplot & Gnuplot::set_style | ( | const std::string & | stylestr = "points" |
) |
set line style (some of these styles require additional information): lines, points, linespoints, impulses, dots, steps, fsteps, histeps, boxes, histograms, filledcurves
Definition at line 995 of file gnuplot_i.hpp.
Referenced by Gnuplot(), and main().
00996 { 00997 if (stylestr.find("lines") == std::string::npos && 00998 stylestr.find("points") == std::string::npos && 00999 stylestr.find("linespoints") == std::string::npos && 01000 stylestr.find("impulses") == std::string::npos && 01001 stylestr.find("dots") == std::string::npos && 01002 stylestr.find("steps") == std::string::npos && 01003 stylestr.find("fsteps") == std::string::npos && 01004 stylestr.find("histeps") == std::string::npos && 01005 stylestr.find("boxes") == std::string::npos && // 1-4 columns of data are required 01006 stylestr.find("filledcurves") == std::string::npos && 01007 stylestr.find("histograms") == std::string::npos ) //only for one data column 01008 // stylestr.find("labels") == std::string::npos && // 3 columns of data are required 01009 // stylestr.find("xerrorbars") == std::string::npos && // 3-4 columns of data are required 01010 // stylestr.find("xerrorlines") == std::string::npos && // 3-4 columns of data are required 01011 // stylestr.find("errorbars") == std::string::npos && // 3-4 columns of data are required 01012 // stylestr.find("errorlines") == std::string::npos && // 3-4 columns of data are required 01013 // stylestr.find("yerrorbars") == std::string::npos && // 3-4 columns of data are required 01014 // stylestr.find("yerrorlines") == std::string::npos && // 3-4 columns of data are required 01015 // stylestr.find("boxerrorbars") == std::string::npos && // 3-5 columns of data are required 01016 // stylestr.find("xyerrorbars") == std::string::npos && // 4,6,7 columns of data are required 01017 // stylestr.find("xyerrorlines") == std::string::npos && // 4,6,7 columns of data are required 01018 // stylestr.find("boxxyerrorbars") == std::string::npos && // 4,6,7 columns of data are required 01019 // stylestr.find("financebars") == std::string::npos && // 5 columns of data are required 01020 // stylestr.find("candlesticks") == std::string::npos && // 5 columns of data are required 01021 // stylestr.find("vectors") == std::string::npos && 01022 // stylestr.find("image") == std::string::npos && 01023 // stylestr.find("rgbimage") == std::string::npos && 01024 // stylestr.find("pm3d") == std::string::npos ) 01025 { 01026 pstyle = std::string("points"); 01027 } 01028 else 01029 { 01030 pstyle = stylestr; 01031 } 01032 01033 return *this; 01034 }
Gnuplot& Gnuplot::set_surface | ( | ) | [inline] |
enables/disables the display of surfaces (for 3d plot)
--- |
Definition at line 332 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
00332 {cmd("set surface");return *this;};
void Gnuplot::set_terminal_std | ( | const std::string & | type | ) | [static] |
optional: set standart terminal, used by showonscreen defaults: Windows - win, Linux - x11, Mac - aqua
type | --> the terminal type |
Definition at line 884 of file gnuplot_i.hpp.
00885 { 00886 #if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) 00887 if (type.find("x11") != std::string::npos && getenv("DISPLAY") == NULL) 00888 { 00889 throw GnuplotException("Can't find DISPLAY variable"); 00890 } 00891 #endif 00892 00893 00894 Gnuplot::terminal_std = type; 00895 return; 00896 }
Gnuplot& Gnuplot::set_title | ( | const std::string & | title = "" |
) | [inline] |
sets and clears the title of a gnuplot session
title | --> the title of the plot [optional, default == ""] |
Definition at line 366 of file gnuplot_i.hpp.
Referenced by main(), and unset_title().
00367 { 00368 std::string cmdstr; 00369 cmdstr = "set title \""; 00370 cmdstr+=title; 00371 cmdstr+="\""; 00372 *this<<cmdstr; 00373 return *this; 00374 }
Gnuplot& Gnuplot::set_xautoscale | ( | ) | [inline] |
Gnuplot & Gnuplot::set_xlabel | ( | const std::string & | label = "y" |
) |
Gnuplot & Gnuplot::set_xlogscale | ( | const double | base = 10 |
) |
turns on/off log scaling for the specified xaxis (logscale is not set by default)
Definition at line 1106 of file gnuplot_i.hpp.
References cmd().
01107 { 01108 std::ostringstream cmdstr; 01109 01110 cmdstr << "set logscale x " << base; 01111 cmd(cmdstr.str()); 01112 01113 return *this; 01114 }
Gnuplot & Gnuplot::set_xrange | ( | const double | iFrom, | |
const double | iTo | |||
) |
set axis - ranges
Definition at line 1252 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01254 { 01255 std::ostringstream cmdstr; 01256 01257 cmdstr << "set xrange[" << iFrom << ":" << iTo << "]"; 01258 cmd(cmdstr.str()); 01259 01260 return *this; 01261 }
Gnuplot& Gnuplot::set_yautoscale | ( | ) | [inline] |
autoscale axis (set by default) of yaxis
--- |
Definition at line 418 of file gnuplot_i.hpp.
References cmd().
Gnuplot & Gnuplot::set_ylabel | ( | const std::string & | label = "x" |
) |
Gnuplot & Gnuplot::set_ylogscale | ( | const double | base = 10 |
) |
turns on/off log scaling for the specified yaxis (logscale is not set by default)
Definition at line 1120 of file gnuplot_i.hpp.
References cmd().
01121 { 01122 std::ostringstream cmdstr; 01123 01124 cmdstr << "set logscale y " << base; 01125 cmd(cmdstr.str()); 01126 01127 return *this; 01128 }
Gnuplot & Gnuplot::set_yrange | ( | const double | iFrom, | |
const double | iTo | |||
) |
set y-axis - ranges
Definition at line 1266 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01268 { 01269 std::ostringstream cmdstr; 01270 01271 cmdstr << "set yrange[" << iFrom << ":" << iTo << "]"; 01272 cmd(cmdstr.str()); 01273 01274 return *this; 01275 }
Gnuplot& Gnuplot::set_zautoscale | ( | ) | [inline] |
autoscale axis (set by default) of zaxis
--- |
Definition at line 427 of file gnuplot_i.hpp.
References cmd().
Gnuplot & Gnuplot::set_zlabel | ( | const std::string & | label = "z" |
) |
Gnuplot & Gnuplot::set_zlogscale | ( | const double | base = 10 |
) |
turns on/off log scaling for the specified zaxis (logscale is not set by default)
Definition at line 1134 of file gnuplot_i.hpp.
References cmd().
01135 { 01136 std::ostringstream cmdstr; 01137 01138 cmdstr << "set logscale z " << base; 01139 cmd(cmdstr.str()); 01140 01141 return *this; 01142 }
Gnuplot & Gnuplot::set_zrange | ( | const double | iFrom, | |
const double | iTo | |||
) |
set z-axis - ranges
Definition at line 1280 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
01282 { 01283 std::ostringstream cmdstr; 01284 01285 cmdstr << "set zrange[" << iFrom << ":" << iTo << "]"; 01286 cmd(cmdstr.str()); 01287 01288 return *this; 01289 }
Gnuplot & Gnuplot::showonscreen | ( | ) |
sets terminal type to terminal_std
Definition at line 1065 of file gnuplot_i.hpp.
References cmd().
Referenced by main(), and reset_all().
01066 { 01067 cmd("set output"); 01068 cmd("set terminal " + Gnuplot::terminal_std); 01069 01070 return *this; 01071 }
Gnuplot& Gnuplot::unset_contour | ( | ) | [inline] |
contour is not set by default, it disables contour drawing for surfaces
--- |
Definition at line 323 of file gnuplot_i.hpp.
References cmd().
00323 {cmd("unset contour");return *this;};
Gnuplot& Gnuplot::unset_grid | ( | ) | [inline] |
grid is not set by default
Definition at line 268 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
00268 {cmd("unset grid");return *this;};
Gnuplot& Gnuplot::unset_hidden3d | ( | ) | [inline] |
hidden3d is not set by default
--- |
Definition at line 311 of file gnuplot_i.hpp.
References cmd().
00311 {cmd("unset hidden3d"); return *this;};
Gnuplot& Gnuplot::unset_legend | ( | ) | [inline] |
Switches legend off attention:legend is set by default.
--- |
Definition at line 357 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
00357 {cmd("unset key"); return *this;}
Gnuplot& Gnuplot::unset_multiplot | ( | ) | [inline] |
unsets the mulitplot mode
--- |
Definition at line 286 of file gnuplot_i.hpp.
References cmd().
00286 {cmd("unset multiplot");return *this;};
Gnuplot& Gnuplot::unset_smooth | ( | ) | [inline] |
unset smooth attention: smooth is not set by default
--- |
Definition at line 259 of file gnuplot_i.hpp.
Referenced by main().
Gnuplot& Gnuplot::unset_surface | ( | ) | [inline] |
surface is set by default, it disables the display of surfaces (for 3d plot)
--- |
Definition at line 342 of file gnuplot_i.hpp.
References cmd().
Referenced by main().
00342 {cmd("unset surface"); return *this;}
Gnuplot& Gnuplot::unset_title | ( | ) | [inline] |
Clears the title of a gnuplot session The title is not set by default.
--- |
Definition at line 384 of file gnuplot_i.hpp.
References set_title().
Referenced by main().
00384 {this->set_title();return *this;}
Gnuplot& Gnuplot::unset_xlogscale | ( | ) | [inline] |
turns off log scaling for the x axis
--- |
Definition at line 444 of file gnuplot_i.hpp.
References cmd().
00444 {cmd("unset logscale x"); return *this;};
Gnuplot& Gnuplot::unset_ylogscale | ( | ) | [inline] |
turns off log scaling for the y axis
--- |
Definition at line 453 of file gnuplot_i.hpp.
References cmd().
00453 {cmd("unset logscale y"); return *this;};
Gnuplot& Gnuplot::unset_zlogscale | ( | ) | [inline] |
turns off log scaling for the z axis
--- |
Definition at line 462 of file gnuplot_i.hpp.
References cmd().
00462 {cmd("unset logscale z"); return *this;};