Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1d23b28

Browse files
biphasiclava
authored andcommitted
added example for fill_inbetween.cpp
1 parent b74e465 commit 1d23b28

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

examples/fill_between.png

24.4 KB
Loading

examples/fill_inbetween.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
}

0 commit comments

Comments
 (0)