Austin Schuh | ab802d5 | 2020-07-03 18:11:11 -0700 | [diff] [blame^] | 1 | #define _USE_MATH_DEFINES |
| 2 | #include "../matplotlibcpp.h" |
| 3 | #include <cmath> |
| 4 | #include <iostream> |
| 5 | |
| 6 | using namespace std; |
| 7 | namespace plt = matplotlibcpp; |
| 8 | |
| 9 | int 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 | } |