Draws the bar plot with string labels on the x-axis (categorical data) # Input `x` -- string labels for each bar (e.g., `["Apple", "Banana", "Orange"]`) `y` -- bar heights (or lengths when horizontal) See also: [`draw`](Self::draw) for numeric x-axis
(&mut self, x: &[&str], y: &'a T)
| 181 | /// |
| 182 | /// See also: [`draw`](Self::draw) for numeric x-axis |
| 183 | pub fn draw_with_str<'a, T, U>(&mut self, x: &[&str], y: &'a T) |
| 184 | where |
| 185 | T: AsVector<'a, U>, |
| 186 | U: 'a + std::fmt::Display + Num, |
| 187 | { |
| 188 | generate_list_quoted(&mut self.buffer, "x", x); |
| 189 | vector_to_array(&mut self.buffer, "y", y); |
| 190 | let opt = self.options(); |
| 191 | if self.colors.len() > 0 { |
| 192 | generate_list_quoted(&mut self.buffer, "colors", self.colors.as_slice()); |
| 193 | } |
| 194 | if self.bottom.len() > 0 { |
| 195 | vector_to_array(&mut self.buffer, "bottom", &self.bottom); |
| 196 | } |
| 197 | if self.errors.len() > 0 { |
| 198 | vector_to_array(&mut self.buffer, "err", &self.errors); |
| 199 | } |
| 200 | if self.horizontal { |
| 201 | write!(&mut self.buffer, "p=plt.barh(x,y{})\n", &opt).unwrap(); |
| 202 | } else { |
| 203 | write!(&mut self.buffer, "p=plt.bar(x,y{})\n", &opt).unwrap(); |
| 204 | } |
| 205 | if let Some(t) = &self.with_text { |
| 206 | write!(&mut self.buffer, "plt.gca().bar_label(p,label_type='{}')\n", t).unwrap(); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | /// Sets the name of this bar series in the legend |
| 211 | /// |