1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-09-20 05:25:37 +01:00

Plot: more ways to plot data

This commit is contained in:
Antonin Portelli 2015-07-07 18:50:36 +01:00
parent cebf2334fa
commit 6202ed4518
2 changed files with 58 additions and 0 deletions

View File

@ -112,6 +112,61 @@ PlotHeadCommand::PlotHeadCommand(const string &command)
}
// PlotData constructor ////////////////////////////////////////////////////////
PlotData::PlotData(const DMatSample &x, const DMatSample &y)
{
if (x[central].rows() != y[central].rows())
{
LATAN_ERROR(Size, "x and y vector does not have the same size");
}
DMat d(x[central].rows(), 4);
string usingCmd, tmpFileName;
d.col(0) = x[central];
d.col(2) = y[central];
d.col(1) = x.variance().cwiseSqrt();
d.col(3) = y.variance().cwiseSqrt();
tmpFileName = dumpToTmpFile(d);
pushTmpFile(tmpFileName);
setCommand("'" + tmpFileName + "' u 1:3:2:4 w xyerr");
}
PlotData::PlotData(const DVec &x, const DMatSample &y)
{
if (x.rows() != y[central].rows())
{
LATAN_ERROR(Size, "x and y vector does not have the same size");
}
DMat d(x.rows(), 3);
string usingCmd, tmpFileName;
d.col(0) = x;
d.col(1) = y[central];
d.col(2) = y.variance().cwiseSqrt();
tmpFileName = dumpToTmpFile(d);
pushTmpFile(tmpFileName);
setCommand("'" + tmpFileName + "' u 1:2:3 w yerr");
}
PlotData::PlotData(const DMatSample &x, const DVec &y)
{
if (x[central].rows() != y.rows())
{
LATAN_ERROR(Size, "x and y vector does not have the same size");
}
DMat d(x[central].rows(), 3), xerr, yerr;
string usingCmd, tmpFileName;
d.col(0) = x[central];
d.col(2) = y;
d.col(1) = x.variance().cwiseSqrt();
tmpFileName = dumpToTmpFile(d);
pushTmpFile(tmpFileName);
setCommand("'" + tmpFileName + "' u 1:3:2 w xerr");
}
PlotData::PlotData(const XYStatData &data, const Index i, const Index j)
{
DMat d(data.getNData(), 4);

View File

@ -88,6 +88,9 @@ class PlotData: public PlotObject
{
public:
// constructor
PlotData(const DMatSample &x, const DMatSample &y);
PlotData(const DVec &x, const DMatSample &y);
PlotData(const DMatSample &x, const DVec &y);
PlotData(const XYStatData &data, const Index i = 0, const Index j = 0);
// destructor
virtual ~PlotData(void) = default;