mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
An interactive c++ interface to gnuplot.
Spawns a gnuplot sesssion and communicates with it.
An example of using gnuPlot to plot data from a file:
Arrays can be plotted directly:
Note that the vector data types are different – this is handled automatically.
To get a response from the gnuplot session:
Error checking and reporting is not straightforward since gnuplot does not return a result if there is no error. If there is an error, it can take several hundred milliseconds for a response to be available. So for a typical plot command, say, one does not want to try to read the stderr ouput just in case as this will just time out with a delay.
For cases where a response is expected, the following example shows how to check for errors.
Definition at line 192 of file gnuPlot.hpp.
#include <math/plot/gnuPlot.hpp>
Public Member Functions | |
int | connect () |
Connect to gnuplot. More... | |
bool | gpError () |
Return the value of the gpError flag. More... | |
std::string | gpErrorMsg () |
Return the gnuplot error message. More... | |
int | command (const std::string &com, bool flush=true) |
Send a command to gnuplot. More... | |
int | checkResponse (std::string &response, double timeout=0) |
Check for a response from gnuplot. More... | |
std::string | getResponse (const std::string &com, double timeout=0.5) |
Get a response from gnuplot for a given command. More... | |
int | replot () |
Issue the replot command. More... | |
int | xrange (double x0, double x1) |
Set the x-axis range. More... | |
int | xrange () |
Unset the x-axis range. More... | |
int | yrange (double y0, double y1) |
Set the y-axis range. More... | |
int | yrange () |
Unset the y-axis range. More... | |
int | logy () |
Set the y axis to log scale. More... | |
int | logx () |
Set the x axis to log scale. More... | |
int | logxy () |
Set the x and y axes to log scale. More... | |
int | ulogy () |
Unset the y axis from log scale. More... | |
int | ulogx () |
Unset the x axis from log scale. More... | |
int | ulogxy () |
Unset the x and y axes from log scale. More... | |
int | plot (const std::string &fname, const std::string &modifiers, const std::string &title, const std::string &name) |
Plot from a file specifying all curve components. More... | |
int | plot (const std::string &fname, const std::string &modifiers, const std::string &name) |
Plot from a file without specifying the title. More... | |
int | plot (const std::string &fname, const std::string &name) |
Plot from a file without modifiers. More... | |
int | plot (const std::string &fname) |
Plot from a file without specifying the name or any modifiers. More... | |
template<typename dataT > | |
int | plot (const dataT *y, size_t N, const std::string &modifiers, const std::string &title, const std::string &name) |
Plot data from an array. More... | |
template<typename dataT > | |
int | plot (const dataT *y, size_t N, const std::string &modifiers, const std::string &name) |
Plot data from an array. More... | |
template<typename dataT > | |
int | plot (const dataT *y, size_t N, const std::string &name) |
Plot data from an array. More... | |
template<typename dataT > | |
int | plot (const dataT *y, size_t N) |
Plot data from an array. More... | |
template<typename dataT > | |
int | plot (const std::vector< dataT > &y, const std::string &modifiers, const std::string &title, const std::string &name) |
Plot data from a vector. More... | |
template<typename dataT > | |
int | plot (const std::vector< dataT > &y, const std::string &modifiers, const std::string &name) |
Plot data from a vector. More... | |
template<typename dataT > | |
int | plot (const std::vector< dataT > &y, const std::string &name) |
Plot data from a vector. More... | |
template<typename dataT > | |
int | plot (const std::vector< dataT > &y) |
Plot data from a vector. More... | |
template<typename dataTx , typename dataTy > | |
int | plot (const dataTx *x, const dataTy *y, size_t N, const std::string &modifiers, const std::string &title, const std::string &name) |
Plot y vs. x data from arrays. More... | |
template<typename dataTx , typename dataTy > | |
int | plot (const dataTx *x, const dataTy *y, size_t N, const std::string &modifiers, const std::string &name) |
Plot y vs. x data from arrays. More... | |
template<typename dataTx , typename dataTy > | |
int | plot (const dataTx *x, const dataTy *y, size_t N, const std::string &name) |
Plot y vs. x data from arrays. More... | |
template<typename dataTx , typename dataTy > | |
int | plot (const dataTx *x, const dataTy *y, size_t N) |
Plot y vs. x data from arrays. More... | |
template<typename dataTx , typename dataTy > | |
int | plot (const std::vector< dataTx > &x, const std::vector< dataTy > &y, const std::string &modifiers, const std::string &title, const std::string &name) |
Plot y vs. x data from vectors. More... | |
template<typename dataTx , typename dataTy > | |
int | plot (const std::vector< dataTx > &x, const std::vector< dataTy > &y, const std::string &modifiers, const std::string &name) |
Plot y vs. x data from vectors. More... | |
template<typename dataTx , typename dataTy > | |
int | plot (const std::vector< dataTx > &x, const std::vector< dataTy > &y, const std::string &name) |
Plot y vs. x data from vectors. More... | |
template<typename dataTx , typename dataTy > | |
int | plot (const std::vector< dataTx > &x, const std::vector< dataTy > &y) |
Plot y vs. x data from vectors. More... | |
template<typename dataTx , typename dataTy > | |
int | point (dataTx x, dataTy y, const std::string &modifiers="", const std::string &title="") |
Plot a single point. More... | |
int | circle (double xcen, double ycen, double radius, const std::string &modifiers="", const std::string &title="", int npoints=10) |
Draw a circle on the plot. More... | |
int | circle (double radius, const std::string &modifiers="", const std::string &title="", int npoints=10) |
Draw a circle on the plot around the origin. More... | |
void | clear () |
Clear all the curves. More... | |
void | reset () |
Clear all the curves and reset plot configuration. More... | |
void | listCurves () |
List the curves and their specifications. More... | |
void | modifiers (const std::string &name, const std::string &modifiers) |
Modify the modifiers for a curve. More... | |
void | title (const std::string &name, const std::string &title) |
Modify the title for a curve. More... | |
Protected Member Functions | |
int | plotImpl (const void *y, size_t Nbytes, const std::string &binary, const std::string &modifiers, const std::string &title, const std::string &name) |
Implementation of 1-D binary plotting. More... | |
int | plotImpl (const void *x, const void *y, size_t Npts, size_t sizex, size_t sizey, const std::string &binaryx, const std::string &binaryy, const std::string &modifiers, const std::string &title, const std::string &name) |
Implementation of 2-d binary plotting. More... | |
int | doPlotCommand () |
Issue the plot command for all the curves. More... | |
FILE * | openTempFile (char *fname) |
Open a temporary binary file, and provide the filename. More... | |
Protected Attributes | |
bool | _gpError {false} |
Set to true if the response indicates a gnuplot error. More... | |
FILE * | _pipeH {0} |
File stream for the gnuplot interface. More... | |
std::string | _errLocation |
Where to create gnuplot stderr fifo. More... | |
std::string | _errFName |
File name of the gnuplot stderr fifo. More... | |
int | _errFD {0} |
File descriptor for the gnuplot stderr fifo. More... | |
std::string | _tempLocation |
Location of temporary files. More... | |
std::vector< std::string > | _tempFiles |
Vector of all temporary file names opened, used for removal on destruction. More... | |
bool | _deleteTemp {true} |
Flag to control whether temporary files are deleted on destruction. Default is true (files deleted). More... | |
int mx::math::gnuPlot::checkResponse | ( | std::string & | response, |
double | timeout = 0 |
||
) |
Check for a response from gnuplot.
It typically takes some time for a response from gnuplot to become readable, whether an error occurs or not. It is often 0.3 seconds or more. If there is no error, there will be no response so waiting for a response to check for errors after every command can be very time consuming. Thus it is a choice whether to check for errors from gnuplot after every command, and what timeout to use.
gnuplot terminates all outputs with \n\n
, so this reads up to these two characters. It then strips any leading and trailing whitespace. If the response begins with gnuplot>
, then the response is an error. In this case, checkResponse returns -1 and the gpError flag is set. If gpError is not set but the return value is -1, then some other error occurred (check errno
).
0 | on timeout or successful read |
-1 | on error, or if the gnuplot response indicates an error. |
[out] | response | contains the response from gnuplot, but is empty on timeout or error. |
[in] | timeout | [optional] the length of time, in seconds, to wait for a response. Default is 0, but a minimum of 0.5 if a response is expected. |
int mx::math::gnuPlot::circle | ( | double | radius, |
const std::string & | modifiers = "" , |
||
const std::string & | title = "" , |
||
int | npoints = 10 |
||
) |
Draw a circle on the plot around the origin.
Creates a circle with radius and center (0,0), and plots it.
[in] | radius | the circle radius |
[in] | modifiers | [optional] contains any modifiers to the plot command other than binary, format, using, and title. |
[in] | title | [optional] contains the title of the data set, default is an empty string and no key on the plot |
[in] | npoints | [optional] specifies the number of points in each half circle. Default 10 is usually sufficient. |
int mx::math::gnuPlot::circle | ( | double | xcen, |
double | ycen, | ||
double | radius, | ||
const std::string & | modifiers = "" , |
||
const std::string & | title = "" , |
||
int | npoints = 10 |
||
) |
Draw a circle on the plot.
Creates a circle with specified center and radius, and plots it.
[in] | xcen | the x-coordinate of the circle center |
[in] | ycen | the y-coordinate of the circle center |
[in] | radius | the circle radius |
[in] | modifiers | [optional] contains any modifiers to the plot command other than binary, format, using, and title. |
[in] | title | [optional] contains the title of the data set, default is an empty string and no key on the plot |
[in] | npoints | [optional] specifies the number of points in each half circle. Default 10 is usually sufficient. |
void mx::math::gnuPlot::clear | ( | ) |
Clear all the curves.
int mx::math::gnuPlot::command | ( | const std::string & | com, |
bool | flush = true |
||
) |
Send a command to gnuplot.
The newline is appended to the command, and then it is sent to gnuplot.
0 | on success |
-1 | on error |
[in] | com | the command string |
[in] | flush | [optional] if true (default), then the output stream is flushed once the command is written |
Referenced by mx::math::eigenPseudoInverse().
int mx::math::gnuPlot::connect | ( | ) |
Connect to gnuplot.
Spawns a gnuplot session using popen with stderr redirected to a temporary file. The temporary file is opened for reading.
0 | on success |
-1 | on error |
|
protected |
Issue the plot command for all the curves.
std::string mx::math::gnuPlot::getResponse | ( | const std::string & | com, |
double | timeout = 0.5 |
||
) |
Get a response from gnuplot for a given command.
This should only be used if a response is expected.
errno
and gpError() should be checked), and the response from gnuplot otherwise. [in] | com | the command string |
[in] | timeout | the length of time, in seconds, to wait for a response. Default is 0.5, which is the minimum that should be used. |
bool mx::math::gnuPlot::gpError | ( | ) |
Return the value of the gpError flag.
This flag is set if gnuplot returns an error message (see checkResponse()). The error message can be accessed with gpErrorMsg().
0 | if no error |
-1 | if an error has occurred. |
std::string mx::math::gnuPlot::gpErrorMsg | ( | ) |
Return the gnuplot error message.
The error message is extracted by checkResponse() when the response from gnuplot begins with "gnuplot>".
void mx::math::gnuPlot::listCurves | ( | ) |
List the curves and their specifications.
int mx::math::gnuPlot::logx | ( | ) |
Set the x axis to log scale.
Sends the command:
set log x
0 | on success |
-1 | on error |
int mx::math::gnuPlot::logxy | ( | ) |
Set the x and y axes to log scale.
Sends the commands:
set log x set log y
0 | on success |
-1 | on error |
int mx::math::gnuPlot::logy | ( | ) |
Set the y axis to log scale.
Sends the command:
set log y
0 | on success |
-1 | on error |
Referenced by mx::math::eigenPseudoInverse().
void mx::math::gnuPlot::modifiers | ( | const std::string & | name, |
const std::string & | modifiers | ||
) |
|
protected |
Open a temporary binary file, and provide the filename.
int mx::math::gnuPlot::plot | ( | const dataT * | y, |
size_t | N | ||
) |
Plot data from an array.
Copies the data in the array to a temporary binary file, and then forms the gnuplot plot command as follows:
* plot "temp-file-name" binary format="%dataT" u 1 t '' *
0 | on success |
-1 | on error |
[in] | y | a pointer to an array of data |
[in] | N | the length of the array |
Definition at line 882 of file gnuPlot.hpp.
References plotImpl().
int mx::math::gnuPlot::plot | ( | const dataT * | y, |
size_t | N, | ||
const std::string & | modifiers, | ||
const std::string & | name | ||
) |
Plot data from an array.
Copies the data in the array to a temporary binary file, and then forms the gnuplot plot command as follows:
* plot "temp-file-name" binary format="%dataT" u 1 t '' <modifiers> *
The modifiers string must NOT contain the binary, format, using, or the title modifiers, but can contain any other modifiers. Title is specified so that the name of the temporary file name is not printed on the plot.
0 | on success |
-1 | on error |
[in] | y | a pointer to an array of data |
[in] | N | the length of the array |
[in] | modifiers | contains any modifiers to the plot command other than binary, format, using, and title. |
[in] | name | the identifying name of this curve |
Definition at line 863 of file gnuPlot.hpp.
References modifiers(), and plotImpl().
int mx::math::gnuPlot::plot | ( | const dataT * | y, |
size_t | N, | ||
const std::string & | modifiers, | ||
const std::string & | title, | ||
const std::string & | name | ||
) |
Plot data from an array.
Copies the data in the array to a temporary binary file, and then forms the gnuplot plot command as follows:
* plot "temp-file-name" binary format="%dataT" u 1 t "title" <modifiers> *
The modifiers string must NOT contain the binary, format, using, or the title modifiers, but can contain any other modifiers. Title is specified so that the name of the temporary file name is not printed on the plot.
0 | on success |
-1 | on error |
[in] | y | a pointer to an array of data |
[in] | N | the length of the array |
[in] | modifiers | contains any modifiers to the plot command other than binary, format, using, and title. |
[in] | title | contains the title of the data set, default is an empty string and no key on the plot |
[in] | name | the identifying name of this curve |
Definition at line 852 of file gnuPlot.hpp.
References modifiers(), plotImpl(), and title().
int mx::math::gnuPlot::plot | ( | const dataT * | y, |
size_t | N, | ||
const std::string & | name | ||
) |
Plot data from an array.
Copies the data in the array to a temporary binary file, and then forms the gnuplot plot command as follows:
* plot "temp-file-name" binary format="%dataT" u 1 t '' <modifiers> *
0 | on success |
-1 | on error |
[in] | y | a pointer to an array of data |
[in] | N | the length of the array |
[in] | name | the identifying name of this curve |
Definition at line 873 of file gnuPlot.hpp.
References plotImpl().
int mx::math::gnuPlot::plot | ( | const dataTx * | x, |
const dataTy * | y, | ||
size_t | N | ||
) |
Plot y vs. x data from arrays.
Copies the data in the arrays to a temporary binary file, and then forms the gnuplot plot command as follows:
* plot "temp-file-name" binary format="%dataTx%dataTy" u 1:2 t '' *
0 | on success |
-1 | on error |
[in] | x | a pointer to an array of data for the independent variable |
[in] | y | a pointer to an array of data for the dependent variable |
[in] | N | the length of the arrays |
Definition at line 957 of file gnuPlot.hpp.
References plotImpl().
int mx::math::gnuPlot::plot | ( | const dataTx * | x, |
const dataTy * | y, | ||
size_t | N, | ||
const std::string & | modifiers, | ||
const std::string & | name | ||
) |
Plot y vs. x data from arrays.
Copies the data in the arrays to a temporary binary file, and then forms the gnuplot plot command as follows:
* plot "temp-file-name" binary format="%dataTx%dataTy" u 1:2 t '' <modifiers> *
The modifiers string must NOT contain the binary, format, using, or the title modifiers, but can contain any other modifiers. Title is specified so that the name of the temporary file name is not printed on the plot.
0 | on success |
-1 | on error |
[in] | x | a pointer to an array of data for the independent variable |
[in] | y | a pointer to an array of data for the dependent variable |
[in] | N | the length of the arrays |
[in] | modifiers | contains any modifiers to the plot command other than binary, format, using, and title. |
[in] | name | the identifying name of the curve |
Definition at line 936 of file gnuPlot.hpp.
References modifiers(), and plotImpl().
int mx::math::gnuPlot::plot | ( | const dataTx * | x, |
const dataTy * | y, | ||
size_t | N, | ||
const std::string & | modifiers, | ||
const std::string & | title, | ||
const std::string & | name | ||
) |
Plot y vs. x data from arrays.
Copies the data in the arrays to a temporary binary file, and then forms the gnuplot plot command as follows:
plot "temp-file-name" binary format="%dataTx%dataTy" u 1:2 t "title" <modifiers>
The modifiers string must NOT contain the binary, format, using, or the title modifiers, but can contain any other modifiers. Title is specified so that the name of the temporary file name is not printed on the plot.
0 | on success |
-1 | on error |
[in] | x | a pointer to an array of data for the independent variable |
[in] | y | a pointer to an array of data for the dependent variable |
[in] | N | the length of the arrays |
[in] | modifiers | contains any modifiers to the plot command other than binary, format, using, and title. |
[in] | title | contains the title of the data set |
[in] | name | the identifying name of the curve |
Definition at line 924 of file gnuPlot.hpp.
References modifiers(), plotImpl(), and title().
int mx::math::gnuPlot::plot | ( | const dataTx * | x, |
const dataTy * | y, | ||
size_t | N, | ||
const std::string & | name | ||
) |
Plot y vs. x data from arrays.
Copies the data in the arrays to a temporary binary file, and then forms the gnuplot plot command as follows:
* plot "temp-file-name" binary format="%dataTx%dataTy" u 1:2 t '' *
0 | on success |
-1 | on error |
[in] | x | a pointer to an array of data for the independent variable |
[in] | y | a pointer to an array of data for the dependent variable |
[in] | N | the length of the arrays |
[in] | name | the identifying name of the curve |
Definition at line 947 of file gnuPlot.hpp.
References plotImpl().
int mx::math::gnuPlot::plot | ( | const std::string & | fname | ) |
Plot from a file without specifying the name or any modifiers.
The file name is used for the identifying name
Forms the gnuplot plot command as follows:
* plot '<fname>' t '' *
The modifiers string can contain any modifiers such as using, etc. Should generally not include title.
0 | on success |
-1 | on error |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
[in] | fname | the name (with full path) of the file containing data to plot |
int mx::math::gnuPlot::plot | ( | const std::string & | fname, |
const std::string & | modifiers, | ||
const std::string & | name | ||
) |
Plot from a file without specifying the title.
Forms the gnuplot plot command as follows:
* plot '<fname>' <modifiers> t '' *
The modifiers string can contain any modifiers such as using, etc. Should generally not include title.
0 | on success |
-1 | on error |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
[in] | fname | the name (with full path) of the file containing data to plot |
[in] | modifiers | contains any modifiers to the plot command. |
[in] | name | the name for this curve. If "" then the curve# is used. |
int mx::math::gnuPlot::plot | ( | const std::string & | fname, |
const std::string & | modifiers, | ||
const std::string & | title, | ||
const std::string & | name | ||
) |
Plot from a file specifying all curve components.
Forms the gnuplot plot command as follows:
* plot '<fname>' <modifiers> t '<title>' *
The modifiers string can contain any modifiers such as using, etc. Should generally not include title.
0 | on success |
-1 | on error |
[in] | fname | the name (with full path) of the file containing data to plot |
[in] | modifiers | contains any modifiers to the plot command. |
[in] | title | the title for this curve |
[in] | name | the name for this curve. If "" then curve# is used. |
Referenced by mx::math::eigenPseudoInverse(), plot(), and point().
int mx::math::gnuPlot::plot | ( | const std::string & | fname, |
const std::string & | name | ||
) |
Plot from a file without modifiers.
The file name is used for the identifying name
Forms the gnuplot plot command as follows:
* plot '<fname>' <modifiers> t '' *
The modifiers string can contain any modifiers such as using, etc. Should generally not include title.
0 | on success |
-1 | on error |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
[in] | fname | the name (with full path) of the file containing data to plot |
[in] | name | the name for this curve. If "" then the curve# is used |
int mx::math::gnuPlot::plot | ( | const std::vector< dataT > & | y | ) |
Plot data from a vector.
Copies the data in the vector to a temporary binary file, and then forms the gnuplot plot command as follows:
* plot "temp-file-name" binary format="%dataT" u 1 t '' *
0 | on success |
-1 | on error |
[in] | y | the vector containing the data |
Definition at line 917 of file gnuPlot.hpp.
int mx::math::gnuPlot::plot | ( | const std::vector< dataT > & | y, |
const std::string & | modifiers, | ||
const std::string & | name | ||
) |
Plot data from a vector.
Copies the data in the vector to a temporary binary file, and then forms the gnuplot plot command as follows:
* plot "temp-file-name" binary format="%dataT" u 1 t '' <modifiers> *
The modifiers string must NOT contain the binary, format, using, or the title modifiers, but can contain any other modifiers. Title is specified so that the name of the temporary file name is not printed on the plot.
0 | on success |
-1 | on error |
[in] | y | the vector containing the data |
[in] | modifiers | contains any modifiers to the plot command other than binary, format, using, and title. |
[in] | name | the identifying name of this curve |
Definition at line 900 of file gnuPlot.hpp.
References modifiers().
int mx::math::gnuPlot::plot | ( | const std::vector< dataT > & | y, |
const std::string & | modifiers, | ||
const std::string & | title, | ||
const std::string & | name | ||
) |
Plot data from a vector.
Copies the data in the vector to a temporary binary file, and then forms the gnuplot plot command as follows:
* plot "temp-file-name" binary format="%dataT" u 1 t "title" <modifiers> *
The modifiers string must NOT contain the binary, format, using, or the title modifiers, but can contain any other modifiers. Title is specified so that the name of the temporary file name is not printed on the plot.
0 | on success |
-1 | on error |
[in] | y | the vector containing the data |
[in] | modifiers | contains any modifiers to the plot command other than binary, format, using, and title. |
[in] | title | contains the title of the data set, default is an empty string and no key on the plot |
[in] | name | the identifying name of this curve |
Definition at line 890 of file gnuPlot.hpp.
References modifiers(), and title().
int mx::math::gnuPlot::plot | ( | const std::vector< dataT > & | y, |
const std::string & | name | ||
) |
Plot data from a vector.
Copies the data in the vector to a temporary binary file, and then forms the gnuplot plot command as follows:
* plot "temp-file-name" binary format="%dataT" u 1 t '' *
0 | on success |
-1 | on error |
[in] | y | the vector containing the data |
[in] | name | the identifying name of this curve |
Definition at line 909 of file gnuPlot.hpp.
int mx::math::gnuPlot::plot | ( | const std::vector< dataTx > & | x, |
const std::vector< dataTy > & | y | ||
) |
Plot y vs. x data from vectors.
Copies the data in the vectors to a temporary binary file, and then forms the gnuplot plot command as follows:
* plot "temp-file-name" binary format="%dataTx%dataTy" u 1:2 t '' *
0 | on success |
-1 | on error |
[in] | x | a vector of data for the independent variable |
[in] | y | a vector of data for the dependent variable |
Definition at line 996 of file gnuPlot.hpp.
References plot().
int mx::math::gnuPlot::plot | ( | const std::vector< dataTx > & | x, |
const std::vector< dataTy > & | y, | ||
const std::string & | modifiers, | ||
const std::string & | name | ||
) |
Plot y vs. x data from vectors.
Copies the data in the vectors to a temporary binary file, and then forms the gnuplot plot command as follows:
plot "temp-file-name" binary format="%dataTx%dataTy" u 1:2 t '' <modifiers>
The modifiers string must NOT contain the binary, format, using, or the title modifiers, but can contain any other modifiers. Title is specified so that the name of the temporary file name is not printed on the plot.
0 | on success |
-1 | on error |
[in] | x | a vector of data for the independent variable |
[in] | y | a vector of data for the dependent variable |
[in] | modifiers | contains any modifiers to the plot command other than binary, format, using, and title. |
[in] | name | the identifying name of the curve |
Definition at line 977 of file gnuPlot.hpp.
References modifiers(), and plot().
int mx::math::gnuPlot::plot | ( | const std::vector< dataTx > & | x, |
const std::vector< dataTy > & | y, | ||
const std::string & | modifiers, | ||
const std::string & | title, | ||
const std::string & | name | ||
) |
Plot y vs. x data from vectors.
Copies the data in the vectors to a temporary binary file, and then forms the gnuplot plot command as follows:
plot "temp-file-name" binary format="%dataTx%dataTy" u 1:2 t "title" <modifiers>
The modifiers string must NOT contain the binary, format, using, or the title modifiers, but can contain any other modifiers. Title is specified so that the name of the temporary file name is not printed on the plot.
0 | on success |
-1 | on error |
[in] | x | a vector of data for the independent variable |
[in] | y | a vector of data for the dependent variable |
[in] | modifiers | contains any modifiers to the plot command other than binary, format, using, and title. |
[in] | title | contains the title of the data set |
[in] | name | the identifying name of the curve |
Definition at line 966 of file gnuPlot.hpp.
References modifiers(), plot(), and title().
int mx::math::gnuPlot::plot | ( | const std::vector< dataTx > & | x, |
const std::vector< dataTy > & | y, | ||
const std::string & | name | ||
) |
Plot y vs. x data from vectors.
Copies the data in the vectors to a temporary binary file, and then forms the gnuplot plot command as follows:
* plot "temp-file-name" binary format="%dataTx%dataTy" u 1:2 t '' *
0 | on success |
-1 | on error |
[in] | x | a vector of data for the independent variable |
[in] | y | a vector of data for the dependent variable |
[in] | name | the identifying name of the curve |
Definition at line 987 of file gnuPlot.hpp.
References plot().
|
protected |
Implementation of 2-d binary plotting.
|
protected |
Implementation of 1-D binary plotting.
Referenced by plot().
int mx::math::gnuPlot::point | ( | dataTx | x, |
dataTy | y, | ||
const std::string & | modifiers = "" , |
||
const std::string & | title = "" |
||
) |
Plot a single point.
Copies the position as a length-1 vector to a temporary binary file, and then plots it.
0 | on success |
-1 | on error |
[in] | x | the independent axis (x) coordinate of the point |
[in] | y | the dependent axis (y) coordinate of the point |
[in] | modifiers | [optional] contains any modifiers to the plot command other than binary, format, using, and title. |
[in] | title | [optional] contains the title of the data set, default is an empty string and no key on the plot |
Definition at line 1004 of file gnuPlot.hpp.
References modifiers(), plot(), and title().
int mx::math::gnuPlot::replot | ( | ) |
Issue the replot command.
0 | on success |
-1 | on error |
void mx::math::gnuPlot::reset | ( | ) |
Clear all the curves and reset plot configuration.
void mx::math::gnuPlot::title | ( | const std::string & | name, |
const std::string & | title | ||
) |
int mx::math::gnuPlot::ulogx | ( | ) |
Unset the x axis from log scale.
Sends the command:
unset log x
0 | on success |
-1 | on error |
int mx::math::gnuPlot::ulogxy | ( | ) |
Unset the x and y axes from log scale.
Sends the command:
unset log x unset log y
0 | on success |
-1 | on error |
int mx::math::gnuPlot::ulogy | ( | ) |
Unset the y axis from log scale.
Sends the command:
unset log y
0 | on success |
-1 | on error |
int mx::math::gnuPlot::xrange | ( | ) |
Unset the x-axis range.
Sends the command:
* unset xrange *
int mx::math::gnuPlot::xrange | ( | double | x0, |
double | x1 | ||
) |
Set the x-axis range.
Sends the command:
* set xrange [x0:x1] *
int mx::math::gnuPlot::yrange | ( | ) |
Unset the y-axis range.
Sends the command:
* unset yrange *
int mx::math::gnuPlot::yrange | ( | double | y0, |
double | y1 | ||
) |
Set the y-axis range.
Sends the command:
* set yrange [y0:y1] *
|
protected |
Flag to control whether temporary files are deleted on destruction. Default is true (files deleted).
Definition at line 225 of file gnuPlot.hpp.
|
protected |
File descriptor for the gnuplot stderr fifo.
Definition at line 214 of file gnuPlot.hpp.
|
protected |
File name of the gnuplot stderr fifo.
Definition at line 211 of file gnuPlot.hpp.
|
protected |
Where to create gnuplot stderr fifo.
Default is /dev/shm/
Definition at line 208 of file gnuPlot.hpp.
|
protected |
Set to true if the response indicates a gnuplot error.
Definition at line 199 of file gnuPlot.hpp.
|
protected |
File stream for the gnuplot interface.
Definition at line 203 of file gnuPlot.hpp.
|
protected |
Vector of all temporary file names opened, used for removal on destruction.
Definition at line 222 of file gnuPlot.hpp.
|
protected |