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
kazu 32674e3fbb many eval things
moved obsolete code
TeX work
2017-04-10 18:20:11 +02:00

72 lines
1.8 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.getAxisX().setLabel(xLabel);
gpplot.getAxisY().setLabel(yLabel);
gpplot.getAxisY2().setLabel(y2Label);
gpplot.add(&lineErr[0]); lineErr[0].getStroke().setWidth(1.5); lineErr[0].getStroke().getColor().setHexStr("#000000");
gpplot.add(&lineErr[1]); lineErr[1].getStroke().setWidth(1.5); lineErr[1].getStroke().getColor().setHexStr("#FF0000");
gpplot.add(&lineErr[2]); lineErr[2].getStroke().setWidth(1.5); lineErr[2].getStroke().getColor().setHexStr("#00FF00");
gpplot.add(&lineErr[3]); lineErr[3].getStroke().setWidth(1.5); lineErr[3].getStroke().getColor().setHexStr("#0000FF");
gpplot.add(&lineB); lineB.getStroke().setWidth(1); lineB.getStroke().getColor().setHexStr("#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