-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAnimation.cpp
More file actions
55 lines (42 loc) · 1.05 KB
/
Animation.cpp
File metadata and controls
55 lines (42 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* @file Animation.cpp
*
* @date 2019-08-03
*
* Copyright (c) organization
*
*/
#include <cmath>
#include <iostream>
#include <vector>
#include <matplotlib_cpp/MatplotlibCpp.hpp>
int main(int argc, char* argv[])
{
pe::vis::Matplotlib mpllib;
if (!mpllib.imported()) {
std::cout << "Failed to import matplotlib library\n";
exit(EXIT_FAILURE);
}
int n = 1000;
std::vector<double> x, y, z;
x.reserve(n);
y.reserve(n);
z.reserve(n);
for (size_t i = 0; i < n; i++) {
x.emplace_back(i * i);
y.emplace_back(std::sin(2 * M_PI * i / 360.0));
z.emplace_back(std::log(i));
if (i % 10 == 0) {
mpllib.clf();
mpllib.plot(x, y,
{
{"label", pe::vis::Matplotlib::createAnyBaseMapData<std::string>("log(x)")},
});
mpllib.xlim(0, n * n);
mpllib.title("Sample figure");
mpllib.legend();
mpllib.pause(0.01);
}
}
return 0;
}