This is my attempt to create simple plot library for C++
. Especially one that is willing to work on Raspberry Pi
devices on arm64
OS.
Note
This library will not display any plots. It can only save them to .png
Why to choose this library when you can use python
and all it goodness like matplotlib
?
Well.. I also do not know. But maybe when writing somethig that need to work without any other programs like amazing gnuplot
, running on constrained hardware resources system maybe it is worth checking out on this something.
#include "yapl.hpp"
#include <iostream>
int main() {
try {
yapl::Plot plot;
plot.addData({10, 50, 30, 10}, {10, 90, 50, 90});
plot.addData({80, 120, 160, 140, 100}, {10, 90, 10, 50, 50});
plot.addData({190, 190, 240, 240, 190}, {10, 90, 90, 50, 50});
plot.addData({270, 270, 320}, {90, 10, 10});
plot.grid(true);
plot.xLabel("X value");
plot.yLabel("Y value");
plot.title("Yet Another Plot Library");
plot.setLabelMaker([](double val) -> std::string {
return "X: " + std::to_string((int)val);
});
plot.save("/YAPL/img/test/example_plot.png", 800, 600);
}
catch (const yapl::Exception& e) {
std::cout << "Caught error during plot generation" << std::endl;
}
return 0;
}
To run documentation just use:
cd docs && mkdocs serve
This software is released under GPLv2+
license.