1+ //
2+ // g++ -g -Wall -o fill_inbetween $(python-config --includes) fill_inbetween.cpp $(python-config --ldflags --embed)
3+ //
4+
15#define _USE_MATH_DEFINES
26#include " ../matplotlibcpp.h"
37#include < cmath>
@@ -7,22 +11,25 @@ using namespace std;
711namespace plt = matplotlibcpp;
812
913int 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- }
14+ // Prepare data.
15+ int n = 5000 ;
16+ std::vector<double > x (n), y (n), z (n), w (n, 2 );
17+ for (int i = 0 ; i < n; ++i) {
18+ x.at (i) = i * i;
19+ y.at (i) = sin (2 * M_PI * i / 360.0 );
20+ z.at (i) = log (i);
21+ }
22+
23+ // Prepare keywords to pass to PolyCollection. See
24+ // https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.fill_between.html
25+ std::map<string, string> keywords;
26+ keywords[" alpha" ] = " 0.4" ;
27+ keywords[" color" ] = " grey" ;
28+ keywords[" hatch" ] = " -" ;
1829
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" ] = " -" ;
30+ plt::fill_between (x, y, z, keywords);
31+ plt::show ();
2532
26- plt::fill_between (x, y, z, keywords );
27- plt::show ( );
33+ plt::detail::_interpreter::kill ( );
34+ return ( 0 );
2835}
0 commit comments