Prev: mframe.html Up Next: graph-drawer.html
Graphs

Graphs are objects which hold a series of datapoints, each consisting of N values (where N is the number of columns in a graph, if a graph is imagined as a table). The graph class provides all properties of such objects, and dgraph (for holding data points) and fgraph (for holding function values) are two realizations of this base class.

According to the general design concepts, setting or reading graph properties can be done via member functions with the same name, so here only the setting version will be presented. Properties are usually compound words (like linewidth), and this name is used as the member function name. There are usually shorthands as well, consisting of the initial letters of the parts of this compound word (in the case of linewidth the shorthand is lw). Graph properties include the following:

drawstyle
This defines the way how a graph is drawn. This is a large and complicated topic, discussed in a separate section. The functions to set the drawstyle is:
graph &drawstyle(const graph_drawer &); 
graph &ds       (const graph_drawer &); // a shorthand for the previous one
Note that the argument of this function is a reference to an object. This object will be clone-copied inside the function, so the original object is left untouched. This means that one has to construct a graph_drawer object, i.e. call its constructor. In addition, modifying member functions can immediately be called on the (temporary) object, for example:
plot("...").ds(vectors().use_color(true));
Here, vectors() creates a temporary object of type vectors, and we immediately call a member function of this object to set a flag (use a color scale as well to indicate the lengths of the arrows)
fillcolor
The color which should be used when filling a region. One can set it via the member function
graph &fillcolor(const color &c);
graph &fc       (const color &c); // shorthand 
Calling this function automatically switches the fill property of the graph to true (see below), since usually one does not set the fillcolor of a graph if he does not want to fill it
fill
If this is set to true, the graph will be usually filled when drawn. If this happens at all, and how exactly the object is filled, depends on the drawstyle (graph_drawer). Set this property with:
graph &fill(bool); 
linecolor
graph &linecolor(const color &);
graph &lc       (const color &); // shorthand 
linewidth
graph &linewidth(const length &d);
graph &lw       (const length &d); // shorthand 
linestyle
The values of this can be sym::solid, sym::dashed or sym::dotted. Set this property via:
graph &linestyle(sym::linestyle);
graph &ls       (sym::linestyle); //shorthand
pointtype
graph &pointtype(point_drawer &);
graph &pt       (point_drawer &);
pointsize
If the drawstyle is points, this dimension specifies the size of the points
graph &pointsize (const length &);
graph &ps        (const length &); //shorthand
pointcolor
If the drawstyle is points, this specifies the color of the points
graph &pointcolor (const color &);
graph &pc         (const color &); //shorthand
legend
The text which should be used as the explanation in the frame for this graph. The member function to set this is:
graph &legend(const var &); // no shorthand exists
legendcolor
The color of the legend. Set it via:
graph &legendcolor(const color &); // no shorthand
p1min, ...
coming soon ...
X- and Y-ranges
These information are used by graph-drawers (they interpret is as they want, but usually in a reasonable way :-). These are meant to provide a way to restrict the visualization of the given data sample to a certain range. These properties can be set with the following member functions:
graph &xmin(double);
graph &xmax(double);
graph &xrange(double,double);
and similar functions for the yrange

Source files:
   graph.h
   graph.cc

   dgraph.h  (data graph)
   dgraph.cc
   
   fgraph.h  (function graph)
   fgraph.cc

Prev: mframe.html Up Next: graph-drawer.html