Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/szymon423/yapl

Another C++ plot library
https://github.com/szymon423/yapl

cario chart cpp17 plot

Last synced: 5 days ago
JSON representation

Another C++ plot library

Awesome Lists containing this project

README

        

![logo](./img/logo.png)

# Yet Another Plot Library
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`

## But Why?
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.

## Example

```cpp
#include "yapl.hpp"
#include

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;
}
```

![output](./img/example_plot.png)

## Documentation
To run documentation just use:
```sh
cd docs && mkdocs serve
```

## Dependencies
- [cario](https://www.cairographics.org/)

## License
This software is released under `GPLv2+` license.