-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFigure.h
More file actions
70 lines (53 loc) · 1.84 KB
/
Copy pathFigure.h
File metadata and controls
70 lines (53 loc) · 1.84 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
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <vector>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
class Figure{
public:
Figure();
~Figure();
void show();
void save(std::string file_name = "plot.png");
private:
void set_plot_style(std::string plot_style);
void draw();
FILE* gnuplot_stream;
std::vector<std::string> temp_data_files;
std::vector<std::string> line_styles;
std::vector<std::string> line_colours;
std::vector<std::string> line_markers;
std::vector<std::string> line_spec;
static int num_figures;
static std::vector<std::string> matlab_line_styles;
static std::vector<std::string> gnuplot_line_styles;
static std::vector<std::string> matlab_line_colours;
static std::vector<std::string> gnuplot_line_colours;
static std::vector<std::string> matlab_line_markers;
static std::vector<std::string> gnuplot_line_markers;
int id;
int num_plots = 0;
public: // VIEZE TEMPLATES
template <typename T, typename D>
void plot(std::vector<T>& x, std::vector<D>& y, std::string plot_style = "-") {
num_plots++;
set_plot_style(plot_style);
std::string filename = "temp"+std::to_string(id)+"data"+std::to_string(num_plots)+".txt";
std::ofstream f(filename);
for (int i = 0; i < x.size(); i++) {
f << x[i] << " " << y[i] << std::endl;
}
temp_data_files.push_back(filename);
}
template <typename T>
void plot(std::vector<T>& y, std::string plot_style = "-"){
num_plots++;
set_plot_style(plot_style);
std::string filename = "temp"+std::to_string(id)+"data"+std::to_string(num_plots)+".txt";
std::ofstream f(filename);
for (int i = 0; i < y.size(); i++) {
f << i << " " << y[i] << std::endl;
}
temp_data_files.push_back(filename);
}
};