Draws the bar plot with numeric x-axis # Input `x` -- bar positions on the x-axis (or values when horizontal) `y` -- bar heights (or lengths when horizontal) See also: [`draw_with_str`](Self::draw_with_str) for string-labeled categories
(&mut self, x: &'a T, y: &'a T)
| 146 | /// |
| 147 | /// See also: [`draw_with_str`](Self::draw_with_str) for string-labeled categories |
| 148 | pub fn draw<'a, T, U>(&mut self, x: &'a T, y: &'a T) |
| 149 | where |
| 150 | T: AsVector<'a, U>, |
| 151 | U: 'a + std::fmt::Display + Num, |
| 152 | { |
| 153 | vector_to_array(&mut self.buffer, "x", x); |
| 154 | vector_to_array(&mut self.buffer, "y", y); |
| 155 | let opt = self.options(); |
| 156 | if self.colors.len() > 0 { |
| 157 | generate_list_quoted(&mut self.buffer, "colors", self.colors.as_slice()); |
| 158 | } |
| 159 | if self.bottom.len() > 0 { |
| 160 | vector_to_array(&mut self.buffer, "bottom", &self.bottom); |
| 161 | } |
| 162 | if self.errors.len() > 0 { |
| 163 | vector_to_array(&mut self.buffer, "err", &self.errors); |
| 164 | } |
| 165 | if self.horizontal { |
| 166 | write!(&mut self.buffer, "p=plt.barh(x,y{})\n", &opt).unwrap(); |
| 167 | } else { |
| 168 | write!(&mut self.buffer, "p=plt.bar(x,y{})\n", &opt).unwrap(); |
| 169 | } |
| 170 | if let Some(t) = &self.with_text { |
| 171 | write!(&mut self.buffer, "plt.gca().bar_label(p,label_type='{}')\n", t).unwrap(); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | /// Draws the bar plot with string labels on the x-axis (categorical data) |
| 176 | /// |