| 74 | } |
| 75 | |
| 76 | std::string error_bar::data_string() { |
| 77 | // send data once more for the bar |
| 78 | const bool has_y_bar = !y_negative_delta_.empty(); |
| 79 | const bool has_x_bar = !x_negative_delta_.empty(); |
| 80 | const bool has_xy_bar = has_y_bar && has_x_bar; |
| 81 | std::stringstream ss; |
| 82 | ss.precision(10); |
| 83 | ss << std::fixed; |
| 84 | if (has_xy_bar) { |
| 85 | for (size_t i = 0; i < y_data_.size(); ++i) { |
| 86 | ss << " " << x_data_[i] << " " << y_data_[i] << " " |
| 87 | << x_data_[i] - x_negative_delta_[i] << " " |
| 88 | << x_data_[i] + x_positive_delta_[i] << " " |
| 89 | << y_data_[i] - y_negative_delta_[i] << " " |
| 90 | << y_data_[i] + y_positive_delta_[i] << "\n"; |
| 91 | } |
| 92 | ss << " e\n"; |
| 93 | } else if (has_x_bar) { |
| 94 | for (size_t i = 0; i < y_data_.size(); ++i) { |
| 95 | ss << " " << x_data_[i] << " " << y_data_[i] << " " |
| 96 | << x_data_[i] - x_negative_delta_[i] << " " |
| 97 | << x_data_[i] + x_positive_delta_[i] << "\n"; |
| 98 | } |
| 99 | ss << " e\n"; |
| 100 | } else if (has_y_bar) { |
| 101 | if (!filled_curve_) { |
| 102 | for (size_t i = 0; i < y_data_.size(); ++i) { |
| 103 | ss << " " << x_data_[i] << " " << y_data_[i] << " " |
| 104 | << y_data_[i] - y_negative_delta_[i] << " " |
| 105 | << y_data_[i] + y_positive_delta_[i] << "\n"; |
| 106 | } |
| 107 | ss << " e\n"; |
| 108 | } else { |
| 109 | for (size_t i = 0; i < y_data_.size(); ++i) { |
| 110 | ss << " " << x_data_[i] << " " |
| 111 | << y_data_[i] + y_positive_delta_[i] << " " |
| 112 | << y_data_[i] - y_negative_delta_[i] << "\n"; |
| 113 | } |
| 114 | ss << " e\n"; |
| 115 | } |
| 116 | } |
| 117 | // send data for foreground line as usual |
| 118 | ss << line::data_string(); |
| 119 | return ss.str(); |
| 120 | } |
| 121 | |
| 122 | bool error_bar::requires_colormap() { return line::requires_colormap(); } |
| 123 | |