pub struct BarChart { /* private fields */ }
Implementations§
Source§impl BarChart
impl BarChart
Sourcepub fn new(v: f64) -> Self
pub fn new(v: f64) -> Self
Examples found in repository?
More examples
examples/with_grid.rs (line 29)
25fn render_barchart<S>(filename: S)
26where
27 S: AsRef<str>,
28{
29 let b1 = BarChart::new(5.3).label("1");
30 let b2 = BarChart::new(2.6)
31 .label("2")
32 .style(&BoxStyle::new().fill("darkolivegreen"));
33 let mut v = CategoricalView::new().add(b1).add(b2).x_label("Experiment");
34 v.add_grid(Grid::new(3, 8));
35 Page::single(&v)
36 .save(filename.as_ref())
37 .expect("saving svg");
38}
examples/letter_counter.rs (line 18)
3fn main() {
4 let mut data = Vec::new();
5 let message: &str = "This is a long message";
6 let mut count = BTreeMap::new();
7
8 for c in message.trim().to_lowercase().chars() {
9 if c.is_alphabetic() {
10 *count.entry(c).or_insert(0) += 1
11 }
12 }
13
14 println!("Number of occurences per character");
15 for (ch, count) in &count {
16 println!("{:?}: {}", ch, count);
17 let count = *count as f64;
18 data.push(plotlib::repr::BarChart::new(count).label(ch.to_string()));
19 }
20 // Add data to the view
21 let v = data
22 .into_iter()
23 .fold(plotlib::view::CategoricalView::new(), |view, datum| {
24 view.add(datum)
25 });
26
27 plotlib::page::Page::single(&v)
28 .save("barchart.svg")
29 .expect("saving svg");
30}
Sourcepub fn style(self, style: &BoxStyle) -> Self
pub fn style(self, style: &BoxStyle) -> Self
Examples found in repository?
More examples
examples/with_grid.rs (line 32)
25fn render_barchart<S>(filename: S)
26where
27 S: AsRef<str>,
28{
29 let b1 = BarChart::new(5.3).label("1");
30 let b2 = BarChart::new(2.6)
31 .label("2")
32 .style(&BoxStyle::new().fill("darkolivegreen"));
33 let mut v = CategoricalView::new().add(b1).add(b2).x_label("Experiment");
34 v.add_grid(Grid::new(3, 8));
35 Page::single(&v)
36 .save(filename.as_ref())
37 .expect("saving svg");
38}
pub fn get_style(&self) -> &BoxStyle
Sourcepub fn label<T>(self, label: T) -> Self
pub fn label<T>(self, label: T) -> Self
Examples found in repository?
More examples
examples/with_grid.rs (line 29)
25fn render_barchart<S>(filename: S)
26where
27 S: AsRef<str>,
28{
29 let b1 = BarChart::new(5.3).label("1");
30 let b2 = BarChart::new(2.6)
31 .label("2")
32 .style(&BoxStyle::new().fill("darkolivegreen"));
33 let mut v = CategoricalView::new().add(b1).add(b2).x_label("Experiment");
34 v.add_grid(Grid::new(3, 8));
35 Page::single(&v)
36 .save(filename.as_ref())
37 .expect("saving svg");
38}
examples/letter_counter.rs (line 18)
3fn main() {
4 let mut data = Vec::new();
5 let message: &str = "This is a long message";
6 let mut count = BTreeMap::new();
7
8 for c in message.trim().to_lowercase().chars() {
9 if c.is_alphabetic() {
10 *count.entry(c).or_insert(0) += 1
11 }
12 }
13
14 println!("Number of occurences per character");
15 for (ch, count) in &count {
16 println!("{:?}: {}", ch, count);
17 let count = *count as f64;
18 data.push(plotlib::repr::BarChart::new(count).label(ch.to_string()));
19 }
20 // Add data to the view
21 let v = data
22 .into_iter()
23 .fold(plotlib::view::CategoricalView::new(), |view, datum| {
24 view.add(datum)
25 });
26
27 plotlib::page::Page::single(&v)
28 .save("barchart.svg")
29 .expect("saving svg");
30}
pub fn get_label(&self) -> &String
Trait Implementations§
Source§impl CategoricalRepresentation for BarChart
impl CategoricalRepresentation for BarChart
Source§fn ticks(&self) -> Vec<String>
fn ticks(&self) -> Vec<String>
The ticks that this representation covers. Used to collect all ticks for display
fn to_svg( &self, x_axis: &CategoricalAxis, y_axis: &ContinuousAxis, face_width: f64, face_height: f64, ) -> Group
fn to_text( &self, _x_axis: &CategoricalAxis, _y_axis: &ContinuousAxis, _face_width: u32, _face_height: u32, ) -> String
Auto Trait Implementations§
impl Freeze for BarChart
impl RefUnwindSafe for BarChart
impl Send for BarChart
impl Sync for BarChart
impl Unpin for BarChart
impl UnwindSafe for BarChart
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more