| 152 | } |
| 153 | |
| 154 | std::string line::data_string() { |
| 155 | const bool markers_are_automatic = marker_indices_.empty(); |
| 156 | // const bool has_line_and_marker = line_spec_.has_line() && |
| 157 | // line_spec_.has_non_custom_marker(); const bool can_plot_together = |
| 158 | // markers_are_automatic && |
| 159 | // line_spec_.can_plot_line_and_marker_together() && |
| 160 | // has_line_and_marker; const bool needs_to_plot_twice = |
| 161 | // !can_plot_together && has_line_and_marker; size_t repetitions = 1 + |
| 162 | // needs_to_plot_twice; |
| 163 | const bool x_is_manual = !x_data_.empty(); |
| 164 | |
| 165 | std::stringstream ss; |
| 166 | ss.precision(10); |
| 167 | ss << std::fixed; |
| 168 | for (const auto &style : styles_to_plot()) { |
| 169 | if (visible_) { |
| 170 | const bool data_is_for_markers = |
| 171 | style == line_spec::style_to_plot::plot_marker_only || |
| 172 | style == line_spec::style_to_plot::plot_marker_face_only; |
| 173 | const bool only_at_marker_indices = |
| 174 | !markers_are_automatic && data_is_for_markers; |
| 175 | const size_t n_points = only_at_marker_indices |
| 176 | ? marker_indices_.size() |
| 177 | : y_data_.size(); |
| 178 | |
| 179 | const bool marker_size_is_variable = !marker_sizes_.empty(); |
| 180 | const bool we_are_plotting_markers = |
| 181 | style != line_spec::style_to_plot::plot_line_only; |
| 182 | const bool include_marker_size = |
| 183 | marker_size_is_variable && we_are_plotting_markers; |
| 184 | const double marker_size_denominator = |
| 185 | style == line_spec::style_to_plot::plot_marker_face_only |
| 186 | ? 10 |
| 187 | : 6; |
| 188 | |
| 189 | const bool color_is_variable = !marker_colors_.empty(); |
| 190 | const bool include_marker_color = |
| 191 | color_is_variable && we_are_plotting_markers; |
| 192 | |
| 193 | for (size_t i = 0; i < n_points; ++i) { |
| 194 | size_t index = |
| 195 | only_at_marker_indices ? marker_indices_[i] : i; |
| 196 | |
| 197 | if (x_is_manual && index >= x_data_.size()) { |
| 198 | break; |
| 199 | } |
| 200 | double x_value = x_is_manual ? x_data_[index] : index + 1; |
| 201 | if (!std::isfinite(x_value) || !std::isfinite(y_data_[i])) { |
| 202 | ss << " \n"; |
| 203 | continue; |
| 204 | } |
| 205 | ss << " " << x_value; |
| 206 | |
| 207 | ss << " " << y_data_[index]; |
| 208 | |
| 209 | if (is_3d()) { |
| 210 | ss << " " << z_data_[index]; |
| 211 | } |