-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cc
42 lines (33 loc) · 836 Bytes
/
main.cc
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
//
// Copyright (c) 2015 Jim Youngquist
// under The MIT License (MIT)
// full text in LICENSE file in root folder of this project.
//
#include <cmath>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "cpp_mpl.hpp"
int main(int argc, char **argv) {
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " /path/to/kernel-PID.json"
<< std::endl;
exit(-1);
}
cppmpl::CppMatplotlib mpl{argv[1]};
mpl.Connect();
std::vector<cppmpl::NumpyArray::dtype> raw_data;
double x = 0.0;
while (x < 3.14159 * 4) {
raw_data.push_back(std::sin(x));
x += 0.05;
}
cppmpl::NumpyArray data("A", raw_data);
mpl.SendData(data);
mpl.RunCode("plot(A)\n"
"title('f(x) = sin(x)')\n"
"xlabel('x')\n"
"ylabel('f(x)')\n");
return 0;
}