| 41 | } |
| 42 | |
| 43 | std::string contours::plot_string() { |
| 44 | make_sure_data_is_preprocessed(); |
| 45 | // double zmax_ = zmax(); |
| 46 | // double zmin_ = zmin(); |
| 47 | auto [min_it, max_it] = |
| 48 | std::minmax_element(levels_.begin(), levels_.end()); |
| 49 | double contour_min_level = *min_it; |
| 50 | double contour_max_level = *max_it; |
| 51 | |
| 52 | std::stringstream ss; |
| 53 | ss.precision(10); |
| 54 | ss << std::fixed; |
| 55 | if (filled_) { |
| 56 | auto [lower_levels, upper_levels] = get_lowers_and_uppers(); |
| 57 | // Command for background filled curve |
| 58 | // The background polygon with the whole area has its level defined |
| 59 | // by the largest polygon. Whatever level is outside this largest |
| 60 | // polygon is the level for the "background". The largest polygon is |
| 61 | // always touching the background because because some polygon |
| 62 | // larger than it would always be touching it. This background |
| 63 | // polygon will appear if we define a level < z_min. |
| 64 | |
| 65 | // We plot background only if one of the levels is below zmin |
| 66 | bool plot_background = lower_levels[0] < zmin_; |
| 67 | if (plot_background) { |
| 68 | auto &largest_segment_with_children = line_segments_[0]; |
| 69 | auto &largest_segment = |
| 70 | std::get<0>(largest_segment_with_children); |
| 71 | size_t line_index = std::get<0>(largest_segment); |
| 72 | size_t segment_begin = std::get<1>(largest_segment); |
| 73 | size_t segment_end = std::get<2>(largest_segment); |
| 74 | bool parent_is_lower_level = |
| 75 | is_lower_level(line_index, segment_begin, segment_end); |
| 76 | auto previous_color = line_spec_.color(); |
| 77 | bool previous_color_manual = line_spec_.user_color(); |
| 78 | if (parent_is_lower_level) { |
| 79 | // background is 1 lower than parent on lower level |
| 80 | size_t level_index = line_index > 0 ? line_index - 1 : 0; |
| 81 | double background_z_level = lower_levels[level_index]; |
| 82 | line_spec_.color(parent_->colormap_interpolation( |
| 83 | background_z_level, contour_min_level, |
| 84 | contour_max_level)); |
| 85 | } else { |
| 86 | // background is 1 higher than parent on upper level |
| 87 | size_t level_index = line_index > 0 ? line_index - 1 : 0; |
| 88 | double background_z_level = upper_levels[level_index]; |
| 89 | line_spec_.color(parent_->colormap_interpolation( |
| 90 | background_z_level, contour_min_level, |
| 91 | contour_max_level)); |
| 92 | } |
| 93 | |
| 94 | std::string ls = |
| 95 | " '-' with filledcurve " + |
| 96 | line_spec_.plot_string( |
| 97 | line_spec::style_to_plot::plot_line_only, false); |
| 98 | // filledcurves need to use the palette to initialize the |
| 99 | // colorbox |
| 100 | ls = |
no test coverage detected