This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
OTHER2017/plots/PlotErrTime.h
2017-04-05 18:45:00 +02:00

72 lines
1.7 KiB
C++

#ifndef PLOTERRTIME_H
#define PLOTERRTIME_H
#include <KLib/misc/gnuplot/Gnuplot.h>
#include <KLib/misc/gnuplot/GnuplotPlot.h>
#include <KLib/misc/gnuplot/GnuplotPlotElementLines.h>
#include <Indoor/data/Timestamp.h>
/**
* plot error behaviour over time
*/
class PlotErrTime {
private:
K::Gnuplot gp;
K::GnuplotPlot gpplot;
K::GnuplotPlotElementLines lineErr[8];
K::GnuplotPlotElementLines lineB;
K::GnuplotPlotElementLines lineC;
public:
/** ctor */
PlotErrTime(const std::string& xLabel, const std::string& yLabel, const std::string& y2Label) {
gpplot.setLabelX(xLabel);
gpplot.setLabelY(yLabel);
gpplot.setLabelY2(y2Label);
gpplot.add(&lineErr[0]); lineErr[0].setLineWidth(1.5); lineErr[0].setColorHex("#000000");
gpplot.add(&lineErr[1]); lineErr[1].setLineWidth(1.5); lineErr[1].setColorHex("#FF0000");
gpplot.add(&lineErr[2]); lineErr[2].setLineWidth(1.5); lineErr[2].setColorHex("#00FF00");
gpplot.add(&lineErr[3]); lineErr[3].setLineWidth(1.5); lineErr[3].setColorHex("#0000FF");
gpplot.add(&lineB); lineB.setLineWidth(1); lineB.setColorHex("#0000ff");
gpplot.add(&lineC);
gpplot.setGrid(true);
}
K::GnuplotPlot& getPlot() {
return gpplot;
}
/** add the give error value to the idx-th error line */
void addErr(const Timestamp t, const float err, const int idx = 0) {
K::GnuplotPoint2 pt(t.sec(), err);
lineErr[idx].add(pt);
}
void addB(const Timestamp t, const float something) {
K::GnuplotPoint2 pt(t.sec(), something);
lineB.add(pt);
}
void addC(const Timestamp t, const float something) {
K::GnuplotPoint2 pt(t.sec(), something);
lineC.add(pt);
}
void plot() {
gp.draw(gpplot);
gp.flush();
}
};
#endif // PLOTERRTIME_H