8 #include <matplot/matplot.h>
11 namespace plt = matplot;
16 const std::vector<double>& t,
const std::vector<double>& d,
17 const std::vector<double>& color) {
18 auto a = plt::plot(t, d);
20 a->color(plt::to_array(color));
24 auto s = plt::scatter(std::vector<double>({x}), std::vector<double>({y}));
25 if (color.size() >= 3) {
26 std::array<float, 3> fc;
27 for (
int i = 0; i < color.size(); ++i) {
39 const F2CSwath& s,
const std::vector<double>& color) {
41 size_t n = line.
size();
50 a->color(plt::to_array(color));
54 const F2CSwaths& s,
const std::vector<std::vector<double>>& color) {
58 std::vector({0x00, 0xff, 0x0}),
59 std::vector({0x15, 0x0f, 0x0b}),
62 for (
int i = 0; i < s.
size(); ++i) {
63 plot(s[i], colors[i]);
72 std::vector({0x00, 0xff, 0x0}),
73 std::vector({0x15, 0x0f, 0x0b}),
82 const std::vector<std::vector<double>>& color) {
83 std::vector<std::vector<int>> color_palette {
84 std::vector({0x00, 0xff, 0x00}), std::vector({0x0f, 0x15, 0x0b}),
85 std::vector({0xff, 0x00, 0x00}), std::vector({0x15, 0x0f, 0x0b}),
86 std::vector({0x00, 0x00, 0xff}), std::vector({0x0b, 0x0f, 0x15}),
87 std::vector({0xff, 0x00, 0xff}), std::vector({0x15, 0x0f, 0x15}),
88 std::vector({0x00, 0xff, 0xff}), std::vector({0x00, 0x15, 0x15}),
89 std::vector({0xff, 0xff, 0x00}), std::vector({0x15, 0x15, 0x00})
91 const size_t CS = color_palette.size();
92 for (
int i = 0; i < vs.size(); ++i) {
94 color_palette[(2*i)%CS], color_palette[((2*i)+1)%CS],
101 const F2CLineString& line,
const std::vector<double>& color) {
103 auto l = plt::plot(comps[0], comps[1]);
104 if (color.size() >= 3) {
105 l->color(plt::to_array(color));
111 const F2CMultiPoint& multipoint,
const std::vector<double>& color) {
112 for (
size_t i = 0; i < multipoint.
size(); ++i) {
119 for (
size_t i = 0; i < multiline.
size(); ++i) {
130 const F2CCell&
cell,
const std::vector<double>& color) {
131 for (
auto&& r :
cell) {
138 for (
auto&& c :
cells) {
145 const std::vector<std::vector<double>>& color) {
146 std::vector<F2CSwathsByCells>
swaths;
147 for (
auto&& r :
route) {
148 plot(r.asLineString());
149 swaths.emplace_back(r.getVectorSwaths());
154 const std::vector<std::vector<double>>& color) {
160 const F2CPath&
path,
const std::vector<std::vector<double>>& color) {
161 if (
path.size() <= 1) {
165 std::vector<std::vector<double>> X(1), Y(1);
166 auto prev_state =
path[0].type;
167 auto prev_dir =
path[0].dir;
168 for (
auto&& s :
path) {
169 X.back().emplace_back(s.point.getX());
170 Y.back().emplace_back(s.point.getY());
171 X.back().emplace_back(s.atEnd().getX());
172 Y.back().emplace_back(s.atEnd().getY());
173 if (s.type != prev_state || s.dir != prev_dir) {
184 std::vector({0x00, 0xff, 0x0}),
185 std::vector({0x15, 0x0f, 0x0b}),
189 for (
size_t i = 0; i < X.size(); ++i) {
190 auto a = plt::plot(X[i], Y[i]);
191 a->color(plt::to_array(colors[i]));
197 const std::vector<double>& color) {
201 const std::vector<double>& color) {
207 const std::vector<double>& poly_color) {
208 for (
auto&& c :
cells) {
214 const std::vector<double>& poly_color,
215 const std::vector<double>& holes_color) {
216 for (
auto&& c :
cells) {
222 const std::vector<double>& poly_color) {
227 const std::vector<double>& poly_color,
228 const std::vector<double>& holes_color) {
229 if (
cell.size() < 1) {
233 for (
size_t i = 0; i <
cell.size() - 1; ++i) {
239 const std::vector<double>& color) {
240 std::vector<double> b_x, b_y;
241 for (
auto&& p :
ring) {
242 b_x.emplace_back(p.getX());
243 b_y.emplace_back(p.getY());
245 auto l = plt::polygon(b_x, b_y)->color(plt::to_array(color));
251 plt::axis(plt::equal);
261 auto cf = plt::gcf(
true);
281 plt::xlim({min, max});
285 plt::ylim({min, max});
289 const std::vector<F2CPoint>&
points) {
290 std::vector<double> x, y;
291 std::transform(
points.begin(),
points.end(), std::back_inserter(x),
292 [](
const F2CPoint& c) ->
double { return c.getX();});
293 std::transform(
points.begin(),
points.end(), std::back_inserter(y),
294 [](
const F2CPoint& c) ->
double { return c.getY();});
299 double h = (max - min) / (N - 1.0);
300 std::vector<double> x(N);
301 for (
size_t i = 0; i < N; ++i) {
308 const std::vector<int>& min,
const std::vector<int>& max,
310 auto v_r =
linspace(min[0], max[0], N);
311 auto v_g =
linspace(min[1], max[1], N);
312 auto v_b =
linspace(min[2], max[2], N);
313 std::vector<std::vector<double>> v;
314 for (
size_t i = 0; i < N; ++i) {
316 std::vector<double>({v_r[i]/255.0, v_g[i]/255.0, v_b[i]/255.0}));