Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
Gnuplot Class Reference

#include <gnuplot_i.hpp>

List of all members.

Public Member Functions

Gnuplotcmd (const std::string &cmdstr)
 send a command to gnuplot
 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
bool is_valid ()
 Is the gnuplot session valid ??
Gnuplotoperator<< (const std::string &cmdstr)
 Sends a command to an active gnuplot session, identical to cmd() send a command to gnuplot using the << operator.
Gnuplotplot_equation (const std::string &equation, const std::string &title="")
Gnuplotplot_equation3d (const std::string &equation, const std::string &title="")
Gnuplotplot_image (const unsigned char *ucPicBuf, const unsigned int iWidth, const unsigned int iHeight, const std::string &title="")
 plot image
Gnuplotplot_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
template<typename X >
Gnuplotplot_x (const X &x, const std::string &title="")
 from std::vector
template<typename X , typename Y >
Gnuplotplot_xy (const X &x, const Y &y, const std::string &title="")
 from data
template<typename X , typename Y , typename E >
Gnuplotplot_xy_err (const X &x, const Y &y, const E &dy, const std::string &title="")
 from data
template<typename X , typename Y , typename Z >
Gnuplotplot_xyz (const X &x, const Y &y, const Z &z, const std::string &title="")
 from std::vector
Gnuplotplotfile_x (const std::string &filename, const unsigned int column=1, const std::string &title="")
Gnuplotplotfile_xy (const std::string &filename, const unsigned int column_x=1, const unsigned int column_y=2, const std::string &title="")
Gnuplotplotfile_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="")
Gnuplotplotfile_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="")
void remove_tmpfiles ()
 deletes temporary files
Gnuplotreplot (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)
Gnuplotreset_all ()
 resets a gnuplot session and sets all variables to default
Gnuplotreset_plot ()
 resets a gnuplot session (next plot will erase previous ones)
Gnuplotsavetops (const std::string &filename="gnuplot_output")
 saves a gnuplot session to a postscript file, filename without extension
Gnuplotset_cbrange (const double iFrom, const double iTo)
 set palette range (autoscale by default)
Gnuplotset_contour (const std::string &position="base")
Gnuplotset_grid ()
 turns grid on/off
Gnuplotset_hidden3d ()
Gnuplotset_isosamples (const int isolines=10)
 set isoline density (grid) for plotting functions as surfaces (for 3d plots)
Gnuplotset_legend (const std::string &position="default")
Gnuplotset_multiplot ()
Gnuplotset_pointsize (const double pointsize=1.0)
 scales the size of the points used in plots
Gnuplotset_samples (const int samples=100)
 set sampling rate of functions, or for interpolating data
Gnuplotset_smooth (const std::string &stylestr="csplines")
Gnuplotset_style (const std::string &stylestr="points")
Gnuplotset_surface ()
Gnuplotset_title (const std::string &title="")
 sets and clears the title of a gnuplot session
Gnuplotset_xautoscale ()
Gnuplotset_xlabel (const std::string &label="y")
 set y axis label
Gnuplotset_xlogscale (const double base=10)
 turns on/off log scaling for the specified xaxis (logscale is not set by default)
Gnuplotset_xrange (const double iFrom, const double iTo)
 set axis - ranges
Gnuplotset_yautoscale ()
Gnuplotset_ylabel (const std::string &label="x")
 set x axis label
Gnuplotset_ylogscale (const double base=10)
 turns on/off log scaling for the specified yaxis (logscale is not set by default)
Gnuplotset_yrange (const double iFrom, const double iTo)
 set y-axis - ranges
Gnuplotset_zautoscale ()
Gnuplotset_zlabel (const std::string &label="z")
 set z axis label
Gnuplotset_zlogscale (const double base=10)
 turns on/off log scaling for the specified zaxis (logscale is not set by default)
Gnuplotset_zrange (const double iFrom, const double iTo)
 set z-axis - ranges
Gnuplotshowonscreen ()
 sets terminal type to terminal_std
Gnuplotunset_contour ()
Gnuplotunset_grid ()
 grid is not set by default
Gnuplotunset_hidden3d ()
Gnuplotunset_legend ()
 Switches legend off attention:legend is set by default.
Gnuplotunset_multiplot ()
Gnuplotunset_smooth ()
 unset smooth attention: smooth is not set by default
Gnuplotunset_surface ()
Gnuplotunset_title ()
 Clears the title of a gnuplot session The title is not set by default.
Gnuplotunset_xlogscale ()
Gnuplotunset_ylogscale ()
Gnuplotunset_zlogscale ()
 ~Gnuplot ()
 destructor: needed to delete temporary files

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)

Private Member Functions

std::string create_tmpfile (std::ofstream &tmp)
 creates tmpfile and returns its name
bool file_available (const std::string &filename)
 checks if file is available
void init ()
 get_program_path(); and popen();

Static Private Member Functions

static bool file_exists (const std::string &filename, int mode=0)
 checks if file exists
static bool get_program_path ()
 gnuplot path found?

Private Attributes

FILE * gnucmd
 pointer to the stream that can be used to write to the pipe
int nplots
 number of plots in session
std::string pstyle
 functions and data are displayed in a defined styles
std::string smooth
 interpolate and approximate data in defined styles (e.g. spline)
std::vector< std::string > tmpfile_list
 list of created tmpfiles
bool two_dim
 true = 2d, false = 3d
bool valid
 validation of gnuplot session

Static Private Attributes

static std::string m_sGNUPlotFileName
 name of executed GNUPlot file
static std::string m_sGNUPlotPath
 gnuplot path
static std::string terminal_std
 standart terminal, used by showonscreen
static int tmpfile_num = 0
 number of all tmpfiles (number of tmpfiles restricted)

Detailed Description

Definition at line 68 of file gnuplot_i.hpp.


Constructor & Destructor Documentation

Gnuplot::Gnuplot ( const std::string &  style = "points") [inline]

set a style during construction

Definition at line 612 of file gnuplot_i.hpp.

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.

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.

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.

destructor: needed to delete temporary files

Definition at line 944 of file gnuplot_i.hpp.


Member Function Documentation

Gnuplot & Gnuplot::cmd ( const std::string &  cmdstr)

send a command to gnuplot

Definition at line 1641 of file gnuplot_i.hpp.

std::string Gnuplot::create_tmpfile ( std::ofstream &  tmp) [private]

creates tmpfile and returns its name

Parameters:
tmp--> points to the tempfile
Returns:
<-- the name of the tempfile

Definition at line 1882 of file gnuplot_i.hpp.

bool Gnuplot::file_available ( const std::string &  filename) [private]

checks if file is available

Parameters:
filename--> the filename
mode--> the mode [optional,default value = 0]
Returns:
file exists (yes == true, no == false)

Definition at line 1859 of file gnuplot_i.hpp.

bool Gnuplot::file_exists ( const std::string &  filename,
int  mode = 0 
) [static, private]

checks if file exists

Parameters:
filename--> the filename
mode--> the mode [optional,default value = 0]
Returns:
file exists (yes == true, no == false)

Definition at line 1825 of file gnuplot_i.hpp.

bool Gnuplot::get_program_path ( ) [static, private]

gnuplot path found?

Parameters:
---
Returns:
<-- found the gnuplot path (yes == true, no == false)

Definition at line 1752 of file gnuplot_i.hpp.

void Gnuplot::init ( ) [private]

get_program_path(); and popen();

Parameters:
-->void
Returns:
<-- void

Definition at line 1688 of file gnuplot_i.hpp.

bool Gnuplot::is_valid ( ) [inline]

Is the gnuplot session valid ??

Parameters:
---
Returns:
true if valid, false if not

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.

Parameters:
cmdstr--> the command string
Returns:
<-- a reference to the gnuplot object

Definition at line 220 of file gnuplot_i.hpp.

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.

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.

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.

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.

template<typename X >
Gnuplot & Gnuplot::plot_x ( const X &  x,
const std::string &  title = "" 
)

from std::vector

Plots a 2d graph from a list of doubles: x.

Definition at line 693 of file gnuplot_i.hpp.

template<typename X , typename Y >
Gnuplot & Gnuplot::plot_xy ( const X &  x,
const Y &  y,
const std::string &  title = "" 
)

from data

Plots a 2d graph from a list of doubles: x y.

Definition at line 727 of file gnuplot_i.hpp.

template<typename X , typename Y , typename E >
Gnuplot & Gnuplot::plot_xy_err ( const X &  x,
const Y &  y,
const E &  dy,
const std::string &  title = "" 
)

from data

-----------------------------------------------------------------------------

plot x,y pairs with dy errorbars

Definition at line 767 of file gnuplot_i.hpp.

template<typename X , typename Y , typename Z >
Gnuplot & Gnuplot::plot_xyz ( const X &  x,
const Y &  y,
const Z &  z,
const std::string &  title = "" 
)

from std::vector

Definition at line 812 of file gnuplot_i.hpp.

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.

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.

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.

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.

deletes temporary files

Definition at line 1948 of file gnuplot_i.hpp.

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)

Parameters:
---
Returns:
---

Definition at line 563 of file gnuplot_i.hpp.

resets a gnuplot session and sets all variables to default

Definition at line 976 of file gnuplot_i.hpp.

resets a gnuplot session (next plot will erase previous ones)

Definition at line 962 of file gnuplot_i.hpp.

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.

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.

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.

bool Gnuplot::set_GNUPlotPath ( const std::string &  path) [static]

optional function: set Gnuplot path manual attention: for windows: path with slash '/' not backslash '\'

Parameters:
path--> the gnuplot path
Returns:
true on success, false otherwise

Definition at line 856 of file gnuplot_i.hpp.

Gnuplot& Gnuplot::set_grid ( ) [inline]

turns grid on/off

Definition at line 266 of file gnuplot_i.hpp.

enables/disables hidden line removal for surface plotting (for 3d plot)

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 302 of file gnuplot_i.hpp.

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.

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.

set the mulitplot mode

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 277 of file gnuplot_i.hpp.

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.

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.

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.

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.

enables/disables the display of surfaces (for 3d plot)

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 332 of file gnuplot_i.hpp.

void Gnuplot::set_terminal_std ( const std::string &  type) [static]

optional: set standart terminal, used by showonscreen defaults: Windows - win, Linux - x11, Mac - aqua

Parameters:
type--> the terminal type
Returns:
---

Definition at line 884 of file gnuplot_i.hpp.

Gnuplot& Gnuplot::set_title ( const std::string &  title = "") [inline]

sets and clears the title of a gnuplot session

Parameters:
title--> the title of the plot [optional, default == ""]
Returns:
<-- reference to the gnuplot object

Definition at line 366 of file gnuplot_i.hpp.

autoscale axis (set by default) of xaxis

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 409 of file gnuplot_i.hpp.

Gnuplot & Gnuplot::set_xlabel ( const std::string &  label = "y")

set y axis label

Definition at line 1211 of file gnuplot_i.hpp.

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.

Gnuplot & Gnuplot::set_xrange ( const double  iFrom,
const double  iTo 
)

set axis - ranges

Definition at line 1252 of file gnuplot_i.hpp.

autoscale axis (set by default) of yaxis

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 418 of file gnuplot_i.hpp.

Gnuplot & Gnuplot::set_ylabel ( const std::string &  label = "x")

set x axis label

Definition at line 1224 of file gnuplot_i.hpp.

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.

Gnuplot & Gnuplot::set_yrange ( const double  iFrom,
const double  iTo 
)

set y-axis - ranges

Definition at line 1266 of file gnuplot_i.hpp.

autoscale axis (set by default) of zaxis

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 427 of file gnuplot_i.hpp.

Gnuplot & Gnuplot::set_zlabel ( const std::string &  label = "z")

set z axis label

Definition at line 1237 of file gnuplot_i.hpp.

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.

Gnuplot & Gnuplot::set_zrange ( const double  iFrom,
const double  iTo 
)

set z-axis - ranges

Definition at line 1280 of file gnuplot_i.hpp.

sets terminal type to terminal_std

Definition at line 1065 of file gnuplot_i.hpp.

contour is not set by default, it disables contour drawing for surfaces

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 323 of file gnuplot_i.hpp.

grid is not set by default

Definition at line 268 of file gnuplot_i.hpp.

hidden3d is not set by default

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 311 of file gnuplot_i.hpp.

Switches legend off attention:legend is set by default.

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 357 of file gnuplot_i.hpp.

unsets the mulitplot mode

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 286 of file gnuplot_i.hpp.

unset smooth attention: smooth is not set by default

Parameters:
---
Returns:
<-- a reference to a gnuplot object

Definition at line 259 of file gnuplot_i.hpp.

surface is set by default, it disables the display of surfaces (for 3d plot)

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 342 of file gnuplot_i.hpp.

Clears the title of a gnuplot session The title is not set by default.

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 384 of file gnuplot_i.hpp.

turns off log scaling for the x axis

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 444 of file gnuplot_i.hpp.

turns off log scaling for the y axis

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 453 of file gnuplot_i.hpp.

turns off log scaling for the z axis

Parameters:
---
Returns:
<-- reference to the gnuplot object

Definition at line 462 of file gnuplot_i.hpp.


Member Data Documentation

FILE* Gnuplot::gnucmd [private]

pointer to the stream that can be used to write to the pipe

Definition at line 75 of file gnuplot_i.hpp.

std::string Gnuplot::m_sGNUPlotFileName [static, private]

name of executed GNUPlot file

Definition at line 94 of file gnuplot_i.hpp.

std::string Gnuplot::m_sGNUPlotPath [static, private]

gnuplot path

Definition at line 96 of file gnuplot_i.hpp.

int Gnuplot::nplots [private]

number of plots in session

Definition at line 81 of file gnuplot_i.hpp.

std::string Gnuplot::pstyle [private]

functions and data are displayed in a defined styles

Definition at line 83 of file gnuplot_i.hpp.

std::string Gnuplot::smooth [private]

interpolate and approximate data in defined styles (e.g. spline)

Definition at line 85 of file gnuplot_i.hpp.

std::string Gnuplot::terminal_std [static, private]

standart terminal, used by showonscreen

Definition at line 98 of file gnuplot_i.hpp.

std::vector<std::string> Gnuplot::tmpfile_list [private]

list of created tmpfiles

Definition at line 87 of file gnuplot_i.hpp.

int Gnuplot::tmpfile_num = 0 [static, private]

number of all tmpfiles (number of tmpfiles restricted)

Definition at line 92 of file gnuplot_i.hpp.

bool Gnuplot::two_dim [private]

true = 2d, false = 3d

Definition at line 79 of file gnuplot_i.hpp.

bool Gnuplot::valid [private]

validation of gnuplot session

Definition at line 77 of file gnuplot_i.hpp.


The documentation for this class was generated from the following file:


cob_people_detection
Author(s): Richard Bormann , Thomas Zwölfer
autogenerated on Mon May 6 2019 02:32:06