MCPcopy Create free account
hub / github.com/alandefreitas/matplotplusplus / plot_string

Method plot_string

source/matplot/core/line_spec.cpp:127–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 }
126
127 std::string line_spec::plot_string(style_to_plot sty, bool include_style) {
128 // plot cos(x) with linespoints linecolor rgb "#000000" dashtype 3
129 // linewidth 3 linetype 4
130 std::string res;
131 if (include_style) {
132 switch (sty) {
133 case style_to_plot::plot_line_and_marker:
134 res += " with linespoints";
135 break;
136 case style_to_plot::plot_line_only:
137 res += " with line";
138 break;
139 case style_to_plot::plot_marker_only:
140 case style_to_plot::plot_marker_face_only:
141 res += " with points";
142 break;
143 }
144 }
145
146 switch (sty) {
147 case style_to_plot::plot_line_and_marker:
148 case style_to_plot::plot_line_only:
149 res += " linecolor rgb \"" + to_string(color_) + "\"";
150 break;
151 case style_to_plot::plot_marker_only:
152 res += " linecolor rgb \"" + to_string(marker_color_) + "\"";
153 break;
154 case style_to_plot::plot_marker_face_only:
155 res += " linecolor rgb \"" + to_string(marker_face_color_) + "\"";
156 break;
157 }
158
159 const bool is_plotting_line =
160 sty == style_to_plot::plot_line_and_marker ||
161 sty == style_to_plot::plot_line_only;
162 if (is_plotting_line) {
163 switch (line_style_) {
164 case line_style::solid_line:
165 res += " dashtype 1";
166 break;
167 case line_style::dashed_line:
168 res += " dashtype '--'";
169 break;
170 case line_style::dotted_line:
171 res += " dashtype '.'";
172 break;
173 case line_style::dash_dot_line:
174 res += " dashtype '-.'";
175 break;
176 default:
177 break;
178 }
179 res += " linewidth " + num2str(line_width_);
180 }
181
182 switch (sty) {
183 case style_to_plot::plot_line_and_marker:
184 case style_to_plot::plot_marker_only:

Callers 3

run_grid_commandMethod · 0.45
run_legend_commandMethod · 0.45

Calls 2

to_stringFunction · 0.85
num2strFunction · 0.85

Tested by

no test coverage detected