Skip to content

Instantly share code, notes, and snippets.

@terasakisatoshi
Created October 13, 2024 02:26
Show Gist options
  • Save terasakisatoshi/1ebe80703242d57d2be96afcde7ccdf5 to your computer and use it in GitHub Desktop.
Save terasakisatoshi/1ebe80703242d57d2be96afcde7ccdf5 to your computer and use it in GitHub Desktop.
matplot/matplot.h C++
// https://github.com/alandefreitas/matplotplusplus
// brew install matplot
// g++ -std=c++17 mpl.cpp -lmatplot
#include <matplot/matplot.h>
#include <cmath>
#include <matplot/matplot.h>
int main() {
using namespace matplot;
std::vector<double> x = linspace(0, 2 * pi);
std::vector<double> y = transform(x, [](auto x) { return sin(x); });
plot(x, y, "-o");
hold(on);
plot(x, transform(y, [](auto y) { return -y; }), "--xr");
plot(x, transform(x, [](auto x) { return x / pi - 1.; }), "-:gs");
plot({1.0, 0.7, 0.4, 0.0, -0.4, -0.7, -1}, "k");
show();
return 0;
}
@terasakisatoshi
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment