8000 Fix indentation in basic example, · michLab/matplotlib-cpp@00a4766 · GitHub
[go: up one dir, main page]

Skip to content
< 8000 header class="HeaderMktg header-logged-out js-details-container js-header Details f4 py-3" role="banner" data-is-top="true" data-color-mode=light data-light-theme=light data-dark-theme=dark>

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 00a4766

Browse files
author
Benno Evers
committed
Fix indentation in basic example,
1 parent 0791945 commit 00a4766

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

examples/basic.cpp

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,38 @@ namespace plt = matplotlibcpp;
77

88
int main()
99
{
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-
}
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+
}
1818

1919
// Set the size of output image = 1200x780 pixels
2020
plt::figure_size(1200, 780);
21+
2122
// Plot line from given x and y data. Color is selected automatically.
2223
plt::plot(x, y);
23-
// Plot a red dashed line from given x and y data.
24-
plt::plot(x, w,"r--");
25-
// Plot a line whose name will show up as "log(x)" in the legend.
26-
plt::named_plot("log(x)", x, z);
27-
28-
// Set x-axis to interval [0,1000000]
29-
plt::xlim(0, 1000*1000);
30-
31-
// Add graph title
32-
plt::title("Sample figure");
33-
// Enable legend.
34-
plt::legend();
35-
// save figure
36-
const char* filename = "./basic.png";
37-
std::cout << "Saving result to " << filename << std::endl;;
38-
plt::save(filename);
24+
25+
// Plot a red dashed line from given x and y data.
26+
plt::plot(x, w,"r--");
27+
28+
// Plot a line whose name will show up as "log(x)" in the legend.
29+
plt::named_plot("log(x)", x, z);
30+
31+
// Set x-axis to interval [0,1000000]
32+
plt::xlim(0, 1000*1000);
33+
34+
// Add graph title
35+
plt::title("Sample figure");
36+
37+
// Enable legend.
38+
plt::legend();
39+
40+
// save figure
41+
const char* filename = "./basic.png";
42+
std::cout << "Saving result to " << filename << std::endl;;
43+
plt::save(filename);
3944
}

0 commit comments

Comments
 (0)
0