blob: 788d0086d02476c9b0be1d0d403bd943f48d59d7 [file] [log] [blame]
Austin Schuhab802d52020-07-03 18:11:11 -07001#define _USE_MATH_DEFINES
2#include "../matplotlibcpp.h"
3#include <cmath>
4#include <iostream>
5
6using namespace std;
7namespace plt = matplotlibcpp;
8
9int main() {
10 // Prepare data.
11 int n = 5000;
12 std::vector<double> x(n), y(n), z(n), w(n, 2);
13 for (int i = 0; i < n; ++i) {
14 x.at(i) = i * i;
15 y.at(i) = sin(2 * M_PI * i / 360.0);
16 z.at(i) = log(i);
17 }
18
19 // Prepare keywords to pass to PolyCollection. See
20 // https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.fill_between.html
21 std::map<string, string> keywords;
22 keywords["alpha"] = "0.4";
23 keywords["color"] = "grey";
24 keywords["hatch"] = "-";
25
26 plt::fill_between(x, y, z, keywords);
27 plt::show();
28}