8000 clang format · Tucker-Coughlin/matplotlib-cpp@033a246 · GitHub
[go: up one dir, main page]

Skip to content

Commit 033a246

Browse files
committed
clang format
1 parent ea526f2 commit 033a246

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

examples/modern.cpp

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
#define _USE_MATH_DEFINES
2-
#include <cmath>
32
#include "../matplotlibcpp.h"
3+
#include <cmath>
44

55
using namespace std;
66
namespace plt = matplotlibcpp;
77

8-
int main()
9-
{
10-
// plot(y) - the x-coordinates are implicitly set to [0,1,...,n)
11-
//plt::plot({1,2,3,4});
12-
13-
// Prepare data for parametric plot.
14-
int n = 5000; // number of data points
15-
vector<double> x(n),y(n);
16-
for(int i=0; i<n; ++i) {
17-
double t = 2*M_PI*i/n;
18-
x.at(i) = 16*sin(t)*sin(t)*sin(t);
19-
y.at(i) = 13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t);
20-
}
8< 8000 span class="diff-text-marker">+
int main() {
9+
// plot(y) - the x-coordinates are implicitly set to [0,1,...,n)
10+
// plt::plot({1,2,3,4});
2111

22-
// plot() takes an arbitrary number of (x,y,format)-triples.
23-
// x must be iterable (that is, anything providing begin(x) and end(x)),
24-
// y must either be callable (providing operator() const) or iterable.
25-
plt::plot(x, y, "r-", x, [](double d) { return 12.5+abs(sin(d)); }, "k-");
12+
// Prepare data for parametric plot.
13+
int n = 5000; // number of data points
14+
vector<double> x(n), y(n), z(n);
15+
for (int i = 0; i < n; ++i) {
16+
double t = 2 * M_PI * i / n;
17+
x.at(i) = 16 * sin(t) * sin(t) * sin(t);
18+
y.at(i) = 13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t);
19+
z.at(i) = 12.5 + abs(sin(x.at(i)));
20+
}
2621

22+
// plot() takes an arbitrary number of (x,y,format)-triples.
23+
// x must be iterable (that is, anything providing begin(x) and end(x)),
24+
// y must either be callable (providing operator() const) or iterable.
25+
plt::plot(x, z, "k-", x, y, "r-");
2726

28-
// show plots
29-
plt::show();
27+
// show plots
28+
plt::show();
3029
}

0 commit comments

Comments
 (0)
0