#include <gnuplot.hh>
Public Member Functions | |
| gnuplot (const bool=true) | |
constructor for the gnuplot class | |
| ~gnuplot () | |
destructor for the gnuplot class | |
| gnuplot & | flush (const bool=true) |
| ends the current plot and flushes all data to Gnuplot | |
| gnuplot & | operator<< (const string) |
| passes a string to Gnuplot as a command | |
| gnuplot & | operator<< (const double) |
| passes a number to Gnuplot for plotting | |
| gnuplot & | operator<< (gnuplot &(*f)(gnuplot &)) |
| void | reset_fp () |
| resets output back to Gnuplot | |
| void | set_fp (FILE *const, const bool=false) |
| redirects output away from the Gnuplot pipe and to a file | |
| void | set_graphs (unsigned short) |
| creates multiple graphs in one plot | |
| void | set_log (const string="") |
| enables log scaling of specified axes | |
| void | set_multiplot (const unsigned char=1, const unsigned char=1) |
| creates tiled plots or plots of multiple datasets | |
| void | set_multiplot (const string) |
| creates tiled plots or plots of multiple datasets | |
| void | set_nolog (const string="") |
| disables log scaling of specified axes | |
| void | set_nomultiplot () |
| disables multiplot mode | |
| void | set_output (const string) |
| creates a Postscript plot | |
| void | set_title (const string) |
| sets the title of the plot | |
| void | set_xlabel (const string) |
| sets the label of the X axis | |
| void | set_xrange (const string) |
| sets the extend of the X axis | |
| void | set_ylabel (const string) |
| sets the label of the Y axis | |
| void | set_yrange (const string) |
| sets the extend of the Y axis | |
| void | set_zlabel (const string) |
| sets the label of the Z axis | |
| void | set_zrange (const string) |
| sets the extend of the Z axis | |
Public Attributes | |
| bool | autoscale |
| if set, autoscale mode is used for every plot | |
| int | pause |
| number of seconds to pause between plots | |
| bool | plot3d |
| make 3-D plots | |
| string | style |
style of the plot, i.e., points, lines, dots, ... | |
| float | time |
| time associated with the current plot | |
| string | title |
| title of the plot | |
| string | xlabel |
| label for the x axis | |
| string | ylabel |
| label for the y axis | |
| string | zlabel |
| label for the z axis | |
|
|
Creates a default |
|
|
Closes the pipe to the object's Gnuplot process with |
|
|
This function is used to terminate the current plot and flush the data to the Gnuplot process. It's optional only in the simplest cases when it's sufficient for ~gnuplot(), called explicitly or at the end of scope, to complete the plot: #include "gnuplot.hh" int main(void) { gnuplot gp; gp << 1 << 2 << ...; } gp.flush(); operator<<(gnuplot& (*f)(gnuplot&)) and a nonmember gnuplot& flush(gnuplot&):gp << flush;
|
|
|
This is the most often used function of this class, and the one that, by far, contains the most logic. It's used to send numbers to be plotted to Gnuplot. For example, if gp << 2 << 3; gp << 2; gp << 3; gp will be expecting more numbers, unless it's the last statement in the program (or gp.~gnuplot() is invoked through a different mechanism) or gp.flush() is called explicitly or, equivalently, by gp << flush; gnuplot object would keep track of the current state. For example, to plot three datasets in one graph:gnuplot gp; gp.set_graphs(3); gp << 1 << 2; // first point of the first dataset gp << 3 << 4; // first point of the second dataset gp << 5 << 6; // first point of the third dataset gp << 7 << 8; // second point of the first dataset ... // same pattern continues gp << flush; // plot is finished |
|
|
Used to pass arbitrary commands to Gnuplot. This member function is intended to extend Gnuplot support beyond the provided interface. For example, if gp << "set title \"{/Symbol=18 r}(t)\"\n";
in 18 pt Symbol font. Many provided interface member functions are implemented like this. Another major use of this function is to plot functions, perhaps together with data:gnuplot gp; gp.set_multiplot(); gp << 0.0 << 0.0 << 1.57 << 1 << 3.14 << 0.0 << flush; gp << "plot sin(x) with lines 2\n";
|
|
|
Used to reverse the action of set_fp(). After invoking this member function, the pipe is restored to point to the original Gnuplot process. |
|
||||||||||||
|
This member function is intended for debugging purposes or if tweaking the produced Gnuplot script is desired. It redirects the output of the API to a file and away from the Gnuplot process. The file pointer is usually provided by c_file_ptr() from gnuplot gp; gp.set_fp(stdout, true); gp.set_graphs(3); gp << 1 << 2; gp << 2 << 3; gp << 3 << 4; ... 1 2 ... <newline> 2 3 ... <newline> 3 4 ... <newline> |
|
|
This member function allows to plot multiple datasets together. The data is expected in the order described under operator<<(double) and set_fp().
|
|
|
Enable a logarithmic scale for the specified axes. The argument can specify the desired axes as well the the log base. If no argument is supplied, the defaults, all axes and base 10, are used. Some examples are: |
|
|
This function parses its string argument and calls set_multiplot(unsigned char, unsigned char) with appropriate arguments. It's intended to be given a command-line option directly, which must be in one of two
|
|
||||||||||||
|
Creates tiled plots or plots of multiple datasets. If called without arguments, it simply plots all datasets in the same window until set_nomultiplot() is invoked. Otherwise, it creates a tile of plots of the specified, M by N, configuration. In the first case, it differs from set_graphs() in two respects: the expected order of data, which a dataset at a time in this mode, and the inability to specify in advance the number of desired plots. In particular, both functionalities can't be utilized simultaneously, i.e., if several datasets are to be be plotted and the plots tiled, set_graphs() must also be used. For example, to produce a 3x3 tile of plots: gnuplot gp; gp.set_multiplot(3,3); // or gp.set_multiplot("3") gp << 1 << 2 << ... << flush; // the first plot gp << 3 << 4 << ... << flush; // the second one, placed next to it ... // and so on, for seven more plots gnuplot gp; gp.set_multiplot(); gp << 1 << 2 << ... << flush; // the first dataset gp << 3 << 4 << ... << flush; // the second one, placed in the same plot ... // and so on, ... |
|
|
Disable logarithmic scaling for the specified axes. For this function, the argument must either specify the axis or be empty, in which case linear scaling is restored for all axes. |
|
|
Disables multiplot mode previously enabled with set_multiplot(unsigned char, unsigned char).
|
|
|
Instead of producing an X display plot, make a Postscript file. If the argument is |
|
|
Sets the title of the plot; it will be placed at the top of the plot in the heading. And if time is not
|
|
|
Sets the label of the X axis.
|
|
|
The range of the X axis is passed as a string in Gnuplot format, omitting the outer brackets. For example, to set the extend of the X axis from -2 to an autoscaled value, gp.set_xrange("-2:*") |
|
|
Sets the label of the Y axis.
|
|
|
Sets the limits of the Y axis.
|
|
|
Sets the label of the Z axis.
|
|
|
Sets the limits of the Z axis.
|
|
|
If set, autoscale mode is used for every plot, not just the first one. Otherwise, only the first plot is auto-scaled, and the following ones inherit those axis limits. This is off by default as it produces very annoying rescaling and recentering of plots when only the central portion is "interesting."
|
|
|
When this variable is set to a positive value, it's interpreted as the number of seconds to pause between successive plots (or screens, if in multiplot mode). If it's equal to -1, StarCluster will exit. And if the value of |
|
|
make 3-D plots |
|
|
This determines the style of the plot. Any valid Gnuplot style can be specified: |
|
|
Holds the time associated with the current plot. If set, this number will be used to add time information to the title of the plot. To make a simple X-Y projection of an N-body system: gnuplot gp; gp.title = "X-Y Positions"; gp.xlabel = "x", gp.ylabel = "y"; while (dyn* r = get_next_dyn()) { gp.time = r->get_system_time(); for_all_leaves(dyn, r, d) gp << d->get_pos()[0] << d->get_pos()[1]; gp << flush; rmtree(r); } time must be set to INVALID_TIME.
|
|
|
This variable holds the title of the plot and is used before the first dataset is given with operator<<(double). It's commonly used in tools utilizing the gnuplot gp; gp.title = "Title Example"; // convenient to use the variable here gp << 1 << 2 << ... << flush; gp.set_title("Another Example"); // here, the function form must be used gp << 2 << 3 << ... << flush; |
|
|
Label for the X axis.
|
|
|
Label for the Y axis.
|
|
|
Label for the Z axis.
|
1.4.3