NPL
Neurological Programs and Libraries
|
Class for creating basic plots of arrays or functions. An example might be: More...
#include <basic_plot.h>
Classes | |
struct | StyleT |
Public Types | |
typedef double(* | Function) (double x) |
Public Member Functions | |
Plotter (size_t xres=1024, size_t yres=768) | |
Constructor. More... | |
void | clear () |
Removes all state variables, including plotted points, and functions. More... | |
int | write (std::string fname) |
Writes the output image to the given file. More... | |
int | write (size_t xres, size_t yres, std::string fname) |
Write the output image with the given (temporary) resolution. Does not affect the internal resolution. More... | |
void | setXRange (double low, double high) |
Sets the x range. To use the extremal values from input arrays just leave these at the default (NAN's) More... | |
void | setYRange (double low, double high) |
Sets the y range. To use the extremal values from input arrays and computed yvalues from functions, just leave these at the default (NAN's) More... | |
void | setRes (size_t xres, size_t yres) |
Sets the default resolution. More... | |
void | addFunc (Function f) |
void | addFunc (const std::string &style, Function f) |
void | addFunc (const StyleT &style, Function f) |
void | addArray (size_t sz, const double *array) |
void | addArray (size_t sz, const double *xarr, const double *yarr) |
void | addArray (const std::string &style, size_t sz, const double *array) |
void | addArray (const StyleT &style, size_t sz, const double *xarr, const double *yarr) |
Public Attributes | |
size_t | res [2] |
double | xrange [2] |
double | yrange [2] |
bool | axes |
std::list< std::tuple< StyleT, Function > > | funcs |
std::list< std::tuple< StyleT, std::vector< double >, std::vector< double > > > | arrs |
std::list< StyleT > | colors |
std::list< StyleT >::iterator | curr_color |
Class for creating basic plots of arrays or functions. An example might be:
Plotter plot;
vector<double> data;
// (fill data)
plot.addArray(data.size(), data.data()); plot.write("data.svg");
Definition at line 45 of file basic_plot.h.
typedef double(* npl::Plotter::Function) (double x) |
Definition at line 106 of file basic_plot.h.
npl::Plotter::Plotter | ( | size_t | xres = 1024 , |
size_t | yres = 768 |
||
) |
Constructor.
void npl::Plotter::addArray | ( | size_t | sz, |
const double * | array | ||
) |
void npl::Plotter::addArray | ( | size_t | sz, |
const double * | xarr, | ||
const double * | yarr | ||
) |
void npl::Plotter::addArray | ( | const std::string & | style, |
size_t | sz, | ||
const double * | array | ||
) |
void npl::Plotter::addArray | ( | const StyleT & | style, |
size_t | sz, | ||
const double * | xarr, | ||
const double * | yarr | ||
) |
void npl::Plotter::addFunc | ( | Function | f | ) |
void npl::Plotter::addFunc | ( | const std::string & | style, |
Function | f | ||
) |
void npl::Plotter::clear | ( | ) |
Removes all state variables, including plotted points, and functions.
void npl::Plotter::setRes | ( | size_t | xres, |
size_t | yres | ||
) |
Sets the default resolution.
xres | Width of output image |
yres | Height of output image |
void npl::Plotter::setXRange | ( | double | low, |
double | high | ||
) |
Sets the x range. To use the extremal values from input arrays just leave these at the default (NAN's)
low | Lower bound |
high | Upper bound |
void npl::Plotter::setYRange | ( | double | low, |
double | high | ||
) |
Sets the y range. To use the extremal values from input arrays and computed yvalues from functions, just leave these at the default (NAN's)
low | Lower bound |
high | Upper bound |
int npl::Plotter::write | ( | std::string | fname | ) |
Writes the output image to the given file.
fname | File name to write to. |
int npl::Plotter::write | ( | size_t | xres, |
size_t | yres, | ||
std::string | fname | ||
) |
Write the output image with the given (temporary) resolution. Does not affect the internal resolution.
xres | X resolution |
yres | Y resolution |
fname | Filename |
std::list<std::tuple<StyleT, std::vector<double>, std::vector<double> > > npl::Plotter::arrs |
Definition at line 125 of file basic_plot.h.
bool npl::Plotter::axes |
Definition at line 120 of file basic_plot.h.
std::list<StyleT> npl::Plotter::colors |
Definition at line 128 of file basic_plot.h.
std::list<StyleT>::iterator npl::Plotter::curr_color |
Definition at line 129 of file basic_plot.h.
Definition at line 122 of file basic_plot.h.
size_t npl::Plotter::res[2] |
Definition at line 117 of file basic_plot.h.
double npl::Plotter::xrange[2] |
Definition at line 118 of file basic_plot.h.
double npl::Plotter::yrange[2] |
Definition at line 119 of file basic_plot.h.