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

Method plot_string

source/matplot/axes_objects/network.cpp:32–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 }
31
32 std::string network::plot_string() {
33 maybe_update_line_spec();
34 maybe_update_graph_layout();
35
36 std::string res;
37 bool first = true;
38 for (const auto &style : styles_to_plot()) {
39 if (!first) {
40 res += ",";
41 }
42 const bool we_are_plotting_line =
43 style == line_spec::style_to_plot::plot_line_only;
44 const bool line_width_is_variable =
45 !line_widths_.empty() && z_data_.empty();
46 const bool we_are_plotting_marker =
47 style != line_spec::style_to_plot::plot_line_only;
48 const bool marker_size_is_variable = !marker_sizes_.empty();
49 const bool color_is_variable = !marker_colors_.empty();
50
51 std::string str;
52 if (we_are_plotting_line && directed_) {
53 str += " '-' with vectors " +
54 line_spec_.plot_string(
55 line_spec::style_to_plot::plot_line_only, false);
56 } else if (we_are_plotting_line && line_width_is_variable) {
57 str += " '-' with filledcurves " +
58 line_spec_.plot_string(
59 line_spec::style_to_plot::plot_line_only, false);
60 } else {
61 str = " '-' " + line_spec_.plot_string(style, true);
62 }
63
64 if (marker_size_is_variable && we_are_plotting_marker) {
65 str = std::regex_replace(str,
66 std::regex(" pointsize \\d*\\.?\\d* "),
67 " pointsize variable ");
68 }
69 if (color_is_variable && we_are_plotting_marker) {
70 str = std::regex_replace(str,
71 std::regex(" linecolor rgb +[^ ]+ "),
72 " linecolor palette ");
73 }
74 if (use_y2_) {
75 str += " xlim x1y2";
76 }
77 res += str;
78 if (first) {
79 first = false;
80 }
81 }
82 if (show_labels_ || !edge_labels_.empty()) {
83 res += ", '-' with labels left font \"Helvetica,11\" offset char 1";
84 }
85 return res;
86 }
87
88 std::string network::legend_string(std::string_view title) {
89 if (line_spec_.has_line() && line_spec_.has_non_custom_marker()) {

Callers 1

legend_stringMethod · 0.45

Calls 1

emptyMethod · 0.80

Tested by

no test coverage detected