-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayout_2x2_example.cpp
More file actions
57 lines (47 loc) · 1.72 KB
/
layout_2x2_example.cpp
File metadata and controls
57 lines (47 loc) · 1.72 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
#include "example_common.hpp"
#include "gnuplotpp/plot.hpp"
#include "gnuplotpp/presets.hpp"
#include <vector>
int main(int argc, char** argv) {
using namespace gnuplotpp;
const std::filesystem::path out_dir =
example_common::parse_out_dir(argc, argv, "out/layout_2x2_example");
FigureSpec fs;
fs.preset = Preset::AIAA_Page;
apply_preset_defaults(fs);
fs.rows = 2;
fs.cols = 2;
fs.formats = {OutputFormat::Pdf, OutputFormat::Svg, OutputFormat::Eps};
fs.title = "State Error Overview";
Figure fig(fs);
const std::vector<std::string> ylabels{
"e_x [m]", "e_y [m]", "e_z [m]", "||e_v|| [m/s]"};
const std::vector<std::string> titles{
"X Position", "Y Position", "Z Position", "Velocity Norm"};
for (int idx = 0; idx < 4; ++idx) {
AxesSpec ax;
ax.title = titles[idx];
ax.xlabel = "t [s]";
ax.ylabel = ylabels[idx];
ax.grid = true;
fig.axes(idx).set(ax);
}
std::vector<double> t;
std::vector<double> ex;
std::vector<double> ey;
std::vector<double> ez;
std::vector<double> ev;
for (int i = 0; i < 250; ++i) {
const double x = static_cast<double>(i) * 0.2;
t.push_back(x);
ex.push_back(8.0 / (1.0 + 0.05 * x));
ey.push_back(6.0 / (1.0 + 0.06 * x));
ez.push_back(5.0 / (1.0 + 0.08 * x));
ev.push_back(0.8 / (1.0 + 0.03 * x));
}
fig.axes(0).add_series(SeriesSpec{.type = SeriesType::Line, .label = "SRIF"}, t, ex);
fig.axes(1).add_series(SeriesSpec{.type = SeriesType::Line, .label = "SRIF"}, t, ey);
fig.axes(2).add_series(SeriesSpec{.type = SeriesType::Line, .label = "SRIF"}, t, ez);
fig.axes(3).add_series(SeriesSpec{.type = SeriesType::Line, .label = "SRIF"}, t, ev);
return example_common::render_figure(fig, out_dir / "figures");
}