@@ -6,29 +6,29 @@ namespace plt = matplotlibcpp;
6
6
7
7
int main ()
8
8
{
9
- // Prepare data.
10
- int n = 5000 ;
11
- std::vector<double > x (n), y (n), z (n), w (n,2 );
12
- for (int i=0 ; i<n; ++i) {
13
- x.at (i) = i*i;
14
- y.at (i) = sin (2 *M_PI*i/360.0 );
15
- z.at (i) = log (i);
16
- }
9
+ // Prepare data.
10
+ int n = 5000 ;
11
+ std::vector<double > x (n), y (n), z (n), w (n,2 );
12
+ for (int i=0 ; i<n; ++i) {
13
+ x.at (i) = i*i;
14
+ y.at (i) = sin (2 *M_PI*i/360.0 );
15
+ z.at (i) = log (i);
16
+ }
17
17
18
- // Plot line from given x and y data. Color is selected automatically.
19
- plt::plot (x, y);
20
- // Plot a red dashed line from given x and y data.
21
- plt::plot (x, w," r--" );
22
- // Plot a line whose name will show up as "log(x)" in the legend.
23
- plt::named_plot (" log(x)" , x, z);
18
+ // Plot line from given x and y data. Color is selected automatically.
19
+ plt::plot (x, y);
20
+ // Plot a red dashed line from given x and y data.
21
+ plt::plot (x, w," r--" );
22
+ // Plot a line whose name will show up as "log(x)" in the legend.
23
+ plt::named_plot (" log(x)" , x, z);
24
24
25
- // Set x-axis to interval [0,1000000]
26
- plt::xlim (0 , 1000 *1000 );
25
+ // Set x-axis to interval [0,1000000]
26
+ plt::xlim (0 , 1000 *1000 );
27
27
28
28
// Add graph title
29
29
plt::title (" sample figure" );
30
- // Enable legend.
31
- plt::legend ();
32
- // save figure
30
+ // Enable legend.
31
+ plt::legend ();
32
+ // save figure
33
33
plt::save (" ./basic.png" );
34
34
}
0 commit comments