Created
October 13, 2024 02:26
-
-
Save terasakisatoshi/1ebe80703242d57d2be96afcde7ccdf5 to your computer and use it in GitHub Desktop.
matplot/matplot.h C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
Author
terasakisatoshi
commented
Oct 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment