golib  0.5
Plotting with Cairo

Classes

class  goPlot::CairoPlot
 Plots a graph with cairo. More...
 
class  goPlot::Graph
 Graph. Contains multiple Object2D and some axes to be drawn. Can also contain other Graphs. More...
 
class  goPlot::GraphAxis
 Axis. More...
 
class  goPlot::Object2DBox
 Box object. Draws a box. More...
 
class  goPlot::Object2DImage
 Image object. More...
 
class  goPlot::Object2DPoints
 Points object. Draws lines connecting the given 2D points. More...
 
class  goPlot::Object2DText
 2D text drawing class. Uses pango with cairo. More...
 
class  goPlot::Points2DT< Real >
 Base class for types which provide 2D points. More...
 
class  goPlot::Points2DSimple< Real >
 Simple 2D points provider. Just stores the points in a C array. More...
 
class  goPlot::Points2DMatrix< T >
 Points2D class for accessing points in a goMath::Matrix. More...
 
class  goPlot::RGBA
 Colour class with alpha channel. More...
 
class  goPlot::Trafo2DT< Real >
 Simple affine transformation representation (2x2 matrix and translation vector). More...
 
class  goPlot::Object2D
 Base class for all 2D drawable objects. More...
 
class  goPlot::LineTraits
 Line properties. More...
 
class  goPlot::FontList
 
class  goPlot::TextTraits
 Text properties. Contains colour and font. More...
 

Typedefs

typedef double goPlot::real
 
typedef Points2DT< goDouble > goPlot::Points2D
 
typedef Trafo2DT< real > goPlot::Trafo2D
 

Functions

goAutoPtr< goPlot::GraphgoPlot::plot (const goMatrixf &curve, goAutoPtr< goPlot::Graph > g=0)
 Plot a curve given as configuration matrix. More...
 
goAutoPtr< goPlot::GraphgoPlot::plot (const goVectorf &x, const goVectorf &y, goAutoPtr< goPlot::Graph > g=0)
 Plot a curve given as coordinate vectors. More...
 
goAutoPtr< goPlot::GraphgoPlot::plot (const goMatrixd &curve, goAutoPtr< goPlot::Graph > g=0)
 Plot a curve given as configuration matrix. More...
 
goAutoPtr< goPlot::GraphgoPlot::plot (const goVectord &x, const goVectord &y, goAutoPtr< goPlot::Graph > g=0)
 Plot a curve given as coordinate vectors. More...
 
bool goPlot::plot (goAutoPtr< goPlot::Graph > g, const goString &filename, int w=600, int h=400)
 Plot a graph to a file. More...
 
void goPlot::plot (goAutoPtr< goPlot::Graph > g, cairo_t *context, int w=600, int h=400)
 @TODO Remove CairoPlot and replace with plot(). Basically we only need this function. More...
 
template<class T >
goAutoPtr< goPlot::Object2DPointsgoPlot::object2D (const goMatrix< T > &curve)
 Create a goPlot::Object2DPoints for use in the goPlot library. More...
 
template<class T >
goAutoPtr< goPlot::Object2DPointsgoPlot::object2D (const goVector< T > &x, const goVector< T > &y)
 Create a goPlot::Object2DPoints for use in the goPlot library. More...
 
template<class T >
goAutoPtr< goPlot::Object2DPointsgoPlot::object2D (const goVector< T > &y)
 Create a goPlot::Object2DPoints for use in the goPlot library. More...
 
goAutoPtr< goPlot::Object2DImagegoPlot::object2DImage (const goSignal3DBase< void > &img)
 Create a goAutoPtr<goPlot::Object2DImage> for use with the goPlot library. More...
 

Detailed Description

See also
goGUI::plot, goGUI::PlotView, goGUI::ImageView

These are the functions and classes related to plotting with Cairo. The main structure to look at is goPlot::Graph. A Graph is created and Object2D type objects can be added to it, each one having their own affine transformation, goPlot::Trafo2D. To draw a curve, e.g. use Object2DPoints and a Points2D derived class like Points2DMatrix, for text labels use Object2DText, for images Object2DImage, and so on. Graph also contains convenience functions to add some objects. You can also use the goPlot::plot functions provided for convenience, which also automatically set the dimensions of the graph. The standard transformation for a graph is identity. Plotting starts at the lower left corner, so if you draw images, you may want to flip the y axis.

This module is still quite new and growing, so more objects and functions may be added.

Function Documentation

◆ object2D() [1/3]

template<class T >
goAutoPtr<goPlot::Object2DPoints> goPlot::object2D ( const goMatrix< T > &  curve)

Create a goPlot::Object2DPoints for use in the goPlot library.

Support function for using the goPlot library.

Parameters
curve2D Points, one per row. N times 2 matrix.
Returns
A goAutoPtr to a goPlot::Object2D that can be given directly to a goPlot::Graph using goPlot::Graph::add().

◆ object2D() [2/3]

template<class T >
goAutoPtr<goPlot::Object2DPoints> goPlot::object2D ( const goVector< T > &  x,
const goVector< T > &  y 
)

Create a goPlot::Object2DPoints for use in the goPlot library.

Support function for using the goPlot library.

Parameters
xx coordinates
yy coordinates (must be of same size as x)
Returns
A goAutoPtr to a goPlot::Object2D that can be given directly to a goPlot::Graph using goPlot::Graph::add().

◆ object2D() [3/3]

template<class T >
goAutoPtr<goPlot::Object2DPoints> goPlot::object2D ( const goVector< T > &  y)

Create a goPlot::Object2DPoints for use in the goPlot library.

Support function for using the goPlot library.

x coordinates will be filled with [0,...,y.getSize() - 1].

Parameters
yy coordinates
Returns
A goPlot::AutoPtr to a goPlot::Object2D that can be given directly to a goPlot::Graph using goPlot::Graph::add().

◆ object2DImage()

goAutoPtr< goPlot::Object2DImage > goPlot::object2DImage ( const goSignal3DBase< void > &  img)

Create a goAutoPtr<goPlot::Object2DImage> for use with the goPlot library.

The given 2D image img is copied into a goPlot::Object2DImage. If img has 3 or 4 channels, they are interpreted as RGB / RGBA and converted to ARGB32 for display. 1-channel images are converted to A8 format, which is only an alpha. It may be a good idea to change this.

Todo:
Convert 1-channel images also to ARGB32
Parameters
imgThe 2D source image.
Returns
The goAutoPtr to the image object.

◆ plot() [1/6]

goAutoPtr< goPlot::Graph > goPlot::plot ( const goMatrixd &  curve,
goAutoPtr< goPlot::Graph g = 0 
)

Plot a curve given as configuration matrix.

The graph will be resized to fit.

Parameters
curveConfiguration matrix, one point per row.
gGraph. If Null, a new graph will be created.
Returns
Pointer to the graph. If g was not null, the same as g.

◆ plot() [2/6]

goAutoPtr< goPlot::Graph > goPlot::plot ( const goMatrixf &  curve,
goAutoPtr< goPlot::Graph g = 0 
)

Plot a curve given as configuration matrix.

The graph will be resized to fit.

Parameters
curveConfiguration matrix, one point per row.
gGraph. If Null, a new graph will be created.
Returns
Pointer to the graph. If g was not null, the same as g.
Examples
karchermean/km.cpp, so3/so3.cpp, and sumproduct/sp.cpp.

◆ plot() [3/6]

goAutoPtr< goPlot::Graph > goPlot::plot ( const goVectord x,
const goVectord y,
goAutoPtr< goPlot::Graph g = 0 
)

Plot a curve given as coordinate vectors.

The graph will be resized to fit.

Parameters
xx coordinates of the points.
yy coordinates of the points.
gGraph. If Null, a new graph will be created.
Returns
Pointer to the graph. If g was not null, the same as g.

◆ plot() [4/6]

goAutoPtr< goPlot::Graph > goPlot::plot ( const goVectorf x,
const goVectorf y,
goAutoPtr< goPlot::Graph g = 0 
)

Plot a curve given as coordinate vectors.

The graph will be resized to fit.

Parameters
xx coordinates of the points.
yy coordinates of the points.
gGraph. If Null, a new graph will be created.
Returns
Pointer to the graph. If g was not null, the same as g.

◆ plot() [5/6]

void goPlot::plot ( goAutoPtr< goPlot::Graph g,
cairo_t *  context,
int  w = 600,
int  h = 400 
)

@TODO Remove CairoPlot and replace with plot(). Basically we only need this function.

Plot to a given Cairo context.

Use the other goPlot::plot function to plot directly to files in a more convenient way.

Parameters
gGraph to plot.
contextCairo context to plot to.
wWidth of the graph in points.
hHeight of the graph in points.

◆ plot() [6/6]

bool goPlot::plot ( goAutoPtr< goPlot::Graph g,
const goString filename,
int  w = 600,
int  h = 400 
)

Plot a graph to a file.

Currently, PDF, EPS and SVG files are supported through the respective functions of Cairo.

Parameters
gGraph to plot.
filenameFilename. The ending determines the format: one of .pdf, .eps, .svg.
wWidth of the result in points
hHeight of the result in points
Returns
True if successful, false otherwise.