-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (35 loc) · 906 Bytes
/
Copy pathmain.cpp
File metadata and controls
39 lines (35 loc) · 906 Bytes
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
#define _USE_MATH_DEFINES // for C++
#include <cmath>
#include "matplotlibcppModified.h"
#include <iostream>
namespace plt = matplotlibcpp;
int main()
{
std::vector<double> t(1000);
std::vector<double> x(t.size());
for(size_t i = 0; i < t.size(); i++) {
t[i] = i / 100.0;
x[i] = sin(2.0 * M_PI * 1.0 * t[i]);
}
Py_Initialize();
if ( Py_IsInitialized() )
{
std::cout << "haha 0" << std::endl;
PyObject *mydic = PyDict_New();
if ( !mydic )
{
std::cout << "mydic error\n";
}
std::cout << "haha 1\n";
plt::xkcd();
std::cout << "haha 2\n";
plt::plot(t, x);
std::cout << "plt::plot\n";
plt::title("AN ORDINARY SIN WAVE");
std::cout << "haha 3\n";
plt::save("xkcd.png");
std::cout << "haha 4\n";
}
Py_Finalize();
return 0;
}