-
Notifications
You must be signed in to change notification settings - Fork 5
/
teleplot.hpp
46 lines (46 loc) · 1.87 KB
/
teleplot.hpp
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
#ifndef TELEPLOT_HPP
#define TELEPLOT_HPP
#include <iostream>
#include <vector>
namespace teleplot {
void plot(std::vector<double> y) {
std::cout << "{\"datasets\":[{\"name\":\"fig1\",\"data\":[";
for(int i=0;i<y.size();i++) {
if(i>0) std::cout << ",";
std::cout << "[" << i << "," << y[i] << "]"; }
std::cout << "]}]}" << std::endl;
}
void plotxy(std::vector<double> x,std::vector<double> y) {
std::cout << "{\"datasets\":[{\"name\":\"fig1\",\"data\":[";
for(int i=0;i<y.size();i++) {
if(i>0) std::cout << ",";
std::cout << "[" << x[i] << "," << y[i] << "]"; }
std::cout << "]}]}" << std::endl;
}
void plot(std::vector<double> y,std::vector<double> y2) {
std::cout << "{\"datasets\":[";
std::cout << "{\"name\":\"fig1\",\"data\":[";
for(int i=0;i<y.size();i++) {
if(i>0) std::cout << ",";
std::cout << "[" << i << "," << y[i] << "]"; }
std::cout << "]},";
std::cout << "{\"name\":\"fig2\",\"data\":[";
for(int i=0;i<y2.size();i++) {
if(i>0) std::cout << ",";
std::cout << "[" << i << "," << y2[i] << "]"; }
std::cout << "]}]}" << std::endl;
}
void plotxy(std::vector<double> x,std::vector<double> y,std::vector<double> x2,std::vector<double> y2) {
std::cout << "{\"datasets\":[{\"name\":\"fig1\",\"data\":[";
for(int i=0;i<y.size();i++) {
if(i>0) std::cout << ",";
std::cout << "[" << x[i] << "," << y[i] << "]"; }
std::cout << "]},";
std::cout << "{\"name\":\"fig2\",\"data\":[";
for(int i=0;i<y2.size();i++) {
if(i>0) std::cout << ",";
std::cout << "[" << x2[i] << "," << y2[i] << "]"; }
std::cout << "]}]}" << std::endl;
}
}
#endif