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

Method legend_string

source/matplot/axes_objects/contours.cpp:474–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

472 }
473
474 std::string contours::legend_string(std::string_view title) {
475 auto [min_level_it, max_level_it] =
476 std::minmax_element(levels_.begin(), levels_.end());
477 double zmax = *max_level_it;
478 double zmin = *min_level_it;
479
480 std::stringstream ss;
481 ss.precision(10);
482 ss << std::fixed;
483 for (size_t i = 0; i < lines_.size(); ++i) {
484 if (i != 0) {
485 ss << ",";
486 }
487 auto previous_color = line_spec_.color();
488 bool previous_color_manual = line_spec_.user_color();
489 if (!previous_color_manual) {
490 line_spec_.color(parent_->colormap_interpolation(
491 (zmax - zmin) - (levels_[i] - zmin), 0., zmax - zmin));
492 }
493 ss << " keyentry "
494 << line_spec_.plot_string(
495 line_spec::style_to_plot::plot_line_only)
496 << " title \"" << escape(title) << "\" ";
497 if (!previous_color_manual) {
498 line_spec_.color(previous_color);
499 line_spec_.user_color(previous_color_manual);
500 }
501 }
502 return ss.str();
503 }
504
505 /// If a line is lower (true) or upper level (false)
506 /// We have to know if it's lower or upper level

Callers

nothing calls this directly

Calls 8

escapeFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
user_colorMethod · 0.80
sizeMethod · 0.45
colorMethod · 0.45
plot_stringMethod · 0.45

Tested by

no test coverage detected