philsupertramp/game-math
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
Plot Class Reference

#include <Plot.h>

Inheritance diagram for Plot:
FunctionPlot ImagePlot ScatterPlot SurfacePlot

Public Member Functions

 Plot (const std::string &title="")
 
void clear_file ()
 
void title (const std::string &title)
 
void xAxis (const std::string &name)
 
void yAxis (const std::string &name)
 
void pointSize (const int &size)
 
void lineWidth (const int &size)
 
void AddData (const Matrix< double > &x, const Matrix< double > &y, const std::string &name, DataTypes dataType=DataTypes::NONE, const char *character=nullptr)
 
void AddData (const Matrix< double > &mat, const std::string &name, DataTypes dataTypeName=DataTypes::NONE, const char *pointChar=nullptr, int dimensions=2)
 
virtual void operator() () const
 

Protected Member Functions

void writeAttributes (FILE *gnuplot) const
 

Protected Attributes

const char * dataFileName
 data storage file name More...
 
const char * plotTypeName
 representation of plot type More...
 
const char * plotType = "plot"
 representation of plot type More...
 
FILE * storageFile = nullptr
 data storage file More...
 
PlotAttributes attributes = {}
 attributes for plot More...
 
int numElements = 0
 number elements within the plot More...
 
PlotBoundary bY {}
 x-axis boundaries for the resulting plot More...
 
PlotBoundary bX {}
 y-axis boundaries for the resulting plot More...
 

Private Member Functions

PlotBoundary getBoundaries (const Matrix< double > &x) const
 

Detailed Description

Represents a data plot, using gnuplot.

Add data using the AddData methods. After you are done, call the plot to display the results.


Examples:

Plot plot("My plot");
plot.AddData({{1, 2}, {2, 3}}, "Some points", DataType::POINT);
plot();
Definition: Plot.h:104
Examples
numerics/analysis/TestDifferentiation.cpp, numerics/lin_alg/TestSVD.cpp, and plot/TestPlot.cpp.

Constructor & Destructor Documentation

◆ Plot()

Plot::Plot ( const std::string &  title = "")
inlineexplicit

default constructor. Prepares context for adding data.

Parameters
titledesired title for plot

Member Function Documentation

◆ AddData() [1/2]

void Plot::AddData ( const Matrix< double > &  mat,
const std::string &  name,
DataTypes  dataTypeName = DataTypes::NONE,
const char *  pointChar = nullptr,
int  dimensions = 2 
)
inline

Appends data to the storage file

Parameters
matmatrix containing dataset
namename of data set
dataTypeNamedesired plot type
dimensionsindicator for dimension of dataset

◆ AddData() [2/2]

void Plot::AddData ( const Matrix< double > &  x,
const Matrix< double > &  y,
const std::string &  name,
DataTypes  dataType = DataTypes::NONE,
const char *  character = nullptr 
)
inline

Helper to add pair-wise elements to plot context

concatenates given X and Y and forwards new matrix to AddData with single matrix argument

Parameters
xx values
yy values
namename of dataset
dataTypeplot data type
Examples
numerics/analysis/TestDifferentiation.cpp, numerics/lin_alg/TestSVD.cpp, and plot/TestPlot.cpp.

◆ clear_file()

void Plot::clear_file ( )
inline

◆ getBoundaries()

PlotBoundary Plot::getBoundaries ( const Matrix< double > &  x) const
inlineprivate

calculates boundaries of given matrix (min and max values)

Parameters
xinput vector to calculate boundaries of
Returns
boundaries of input

◆ lineWidth()

void Plot::lineWidth ( const int &  size)
inline

setter for line width of plot data

Parameters
sizedesired line size

◆ operator()()

virtual void Plot::operator() ( ) const
inlinevirtual

execution using call operator

Forwards data to gnuplot

Reimplemented in SurfacePlot.

◆ pointSize()

void Plot::pointSize ( const int &  size)
inline

setter for point size of plot data

Parameters
sizedesired point size
Examples
plot/TestPlot.cpp.

◆ title()

void Plot::title ( const std::string &  title)
inline

Setter for title label

Parameters
titledesired plot title

◆ writeAttributes()

void Plot::writeAttributes ( FILE *  gnuplot) const
inlineprotected

helper to write attributes to gnuplot context

Parameters
gnuplotpointer to gnuplot stream

◆ xAxis()

void Plot::xAxis ( const std::string &  name)
inline

Setter for x-axis label

Parameters
namedesired label name
Examples
plot/TestPlot.cpp.

◆ yAxis()

void Plot::yAxis ( const std::string &  name)
inline

Setter for y-axis label

Parameters
namedesired label name
Examples
plot/TestPlot.cpp.

Member Data Documentation

◆ attributes

PlotAttributes Plot::attributes = {}
protected

attributes for plot

◆ bX

PlotBoundary Plot::bX {}
protected

y-axis boundaries for the resulting plot

◆ bY

PlotBoundary Plot::bY {}
protected

x-axis boundaries for the resulting plot

◆ dataFileName

const char* Plot::dataFileName
protected

data storage file name

◆ numElements

int Plot::numElements = 0
protected

number elements within the plot

◆ plotType

const char* Plot::plotType = "plot"
protected

representation of plot type

◆ plotTypeName

const char* Plot::plotTypeName
protected

representation of plot type

◆ storageFile

FILE* Plot::storageFile = nullptr
protected

data storage file


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