13#include <MachineLearning/FgColor.h>
14#include <MachineLearning/FgWindow.h>
22 namespace MachineLearning
28 Point2(
float x,
float y) : x(x), y(y) {}
35 Point3(
float x,
float y,
float z) : x(x), y(y), z(z) {}
56 Series(
const std::string& label,
enum Type type,
Color color);
58 Series& type(
enum Type type);
60 Series& dynamicColor(
bool dynamic_color);
61 Series& legend(
bool legend);
62 Series& add(
const cv::Mat& data);
63 Series& add(
const std::vector<std::pair<float, float>>& data);
64 Series& add(
const std::vector<std::pair<float, Point2>>& data);
65 Series& add(
const std::vector<std::pair<float, Point3>>& data);
66 Series& addValue(
const std::vector<float>& values);
67 Series& addValue(
const std::vector<Point2>& values);
68 Series& addValue(
const std::vector<Point3>& values);
69 Series& add(
float key,
float value);
72 Series& addValue(
float value);
73 Series& addValue(
float value_a,
float value_b);
74 Series& addValue(
float value_a,
float value_b,
float value_c);
75 Series& set(
const cv::Mat& data);
76 Series& set(
const std::vector<std::pair<float, float>>& data);
77 Series& set(
const std::vector<std::pair<float, Point2>>& data);
78 Series& set(
const std::vector<std::pair<float, Point3>>& data);
79 Series& setValue(
const std::vector<float>& values);
80 Series& setValue(
const std::vector<Point2>& values);
81 Series& setValue(
const std::vector<Point3>& values);
82 Series& set(
float key,
float value);
83 Series& set(
float key,
float value_a,
float value_b);
84 Series& set(
float key,
float value_a,
float value_b,
float value_c);
85 Series& setValue(
float value);
86 Series& setValue(
float value_a,
float value_b);
87 Series& setValue(
float value_a,
float value_b,
float value_c);
90 const std::string& label()
const;
93 void draw(
void* buffer,
float x_min,
float x_max,
float y_min,
float y_max,
94 float x_axis,
float xs,
float xd,
float ys,
float yd,
float y_axis,
95 int unit,
float offset)
const;
96 bool collides()
const;
97 void dot(
void* b,
int x,
int y,
int r)
const;
98 void bounds(
float& x_min,
float& x_max,
float& y_min,
float& y_max,
99 int& n_max,
int& p_max)
const;
100 void verifyParams()
const;
103 void ensureDimsDepth(
int dims,
int depth);
104 bool flipAxis()
const;
107 std::vector<int> entries_;
108 std::vector<float> data_;
124 Figure& origin(
bool x,
bool y);
125 Figure& square(
bool square);
128 Figure& gridSize(
int size);
133 Color backgroundColor();
135 Color subaxisColor();
138 void draw(
void* b,
float x_min,
float x_max,
float y_min,
float y_max,
139 int n_max,
int p_max)
const;
140 void show(
bool flush =
true)
const;
141 Series& series(
const std::string& label);
145 std::vector<Series> series_;
147 Color background_color_;
149 Color sub_axis_color_;
151 bool include_zero_x_;
152 bool include_zero_y_;
160 std::map<std::string, Figure> shared_figures_;
163 Figure& figure(
const std::string& name)
165 if (shared_figures_.count(name) == 0) {
166 auto& view = Window::current().view(name.c_str());
167 shared_figures_.insert(
168 std::map<std::string, Figure>::value_type(name, Figure(view)));
170 return shared_figures_.at(name);