pub struct Page<'a> { /* private fields */ }
Expand description
A single page page laying out the views in a grid
Implementations§
Source§impl<'a> Page<'a>
impl<'a> Page<'a>
Sourcepub fn single(view: &'a dyn View) -> Self
pub fn single(view: &'a dyn View) -> Self
Creates a plot containing a single view
Examples found in repository?
More examples
examples/with_grid.rs (line 20)
12fn render_line_chart<S>(filename: S)
13where
14 S: AsRef<str>,
15{
16 let l1 = Plot::new(vec![(0., 1.), (2., 1.5), (3., 1.2), (4., 1.1)])
17 .line_style(LineStyle::new().colour("burlywood"));
18 let mut v = ContinuousView::new().add(l1);
19 v.add_grid(Grid::new(3, 8));
20 Page::single(&v)
21 .save(filename.as_ref())
22 .expect("saving svg");
23}
24
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/line_and_point_svg.rs (line 16)
6fn main() {
7 let l1 = Plot::new(vec![(0., 1.), (2., 1.5), (3., 1.2), (4., 1.1)])
8 .line_style(
9 LineStyle::new()
10 .colour("burlywood")
11 .linejoin(LineJoin::Round),
12 )
13 .point_style(PointStyle::new());
14
15 let v = ContinuousView::new().add(l1);
16 Page::single(&v)
17 .save("line_and_point.svg")
18 .expect("saving svg");
19}
Additional examples can be found in:
Sourcepub fn dimensions(self, x: u32, y: u32) -> Self
pub fn dimensions(self, x: u32, y: u32) -> Self
Set the dimensions of the plot.
Examples found in repository?
More examples
examples/boxplot_svg.rs (line 19)
6fn main() {
7 let b1 = BoxPlot::from_slice(&[1.0, 4.0, 2.0, 3.5, 6.4, 2.5, 7.5, 1.8, 9.6]).label("1");
8 let b2 = BoxPlot::from_slice(&[3.0, 4.3, 2.0, 3.5, 6.9, 4.5, 7.5, 1.8, 10.6])
9 .label("2")
10 .style(&BoxStyle::new().fill("darkolivegreen"));
11
12 let v = CategoricalView::new()
13 .add(b1)
14 .add(b2)
15 .x_label("Experiment")
16 .y_label("y");
17
18 Page::single(&v)
19 .dimensions(400, 300)
20 .save("boxplot.svg")
21 .expect("saving svg");
22}
examples/scatter_text.rs (line 27)
6fn main() {
7 let data = vec![
8 (-3.0, 2.3),
9 (-1.6, 5.3),
10 (0.3, 0.7),
11 (4.3, -1.4),
12 (6.4, 4.3),
13 (8.5, 3.7),
14 ];
15 let s1 = Plot::new(data).point_style(PointStyle::new().marker(PointMarker::Circle));
16 let s2 = Plot::new(vec![(-1.4, 2.5), (7.2, -0.3)])
17 .point_style(PointStyle::new().marker(PointMarker::Square));
18
19 let v = ContinuousView::new()
20 .add(s1)
21 .add(s2)
22 .x_range(-5., 10.)
23 .y_range(-2., 6.)
24 .x_label("Some varying variable")
25 .y_label("The response of something");
26
27 println!("{}", Page::single(&v).dimensions(80, 30).to_text().unwrap());
28}
Sourcepub fn to_text(&self) -> Result<String, Error>
pub fn to_text(&self) -> Result<String, Error>
Render the plot to an String
Examples found in repository?
More examples
examples/scatter_text.rs (line 27)
6fn main() {
7 let data = vec![
8 (-3.0, 2.3),
9 (-1.6, 5.3),
10 (0.3, 0.7),
11 (4.3, -1.4),
12 (6.4, 4.3),
13 (8.5, 3.7),
14 ];
15 let s1 = Plot::new(data).point_style(PointStyle::new().marker(PointMarker::Circle));
16 let s2 = Plot::new(vec![(-1.4, 2.5), (7.2, -0.3)])
17 .point_style(PointStyle::new().marker(PointMarker::Square));
18
19 let v = ContinuousView::new()
20 .add(s1)
21 .add(s2)
22 .x_range(-5., 10.)
23 .y_range(-2., 6.)
24 .x_label("Some varying variable")
25 .y_label("The response of something");
26
27 println!("{}", Page::single(&v).dimensions(80, 30).to_text().unwrap());
28}
Sourcepub fn save<P>(&self, path: P) -> Result<(), Error>
pub fn save<P>(&self, path: P) -> Result<(), Error>
Save the plot to a file.
The type of file will be based on the file extension.
Examples found in repository?
More examples
examples/with_grid.rs (line 21)
12fn render_line_chart<S>(filename: S)
13where
14 S: AsRef<str>,
15{
16 let l1 = Plot::new(vec![(0., 1.), (2., 1.5), (3., 1.2), (4., 1.1)])
17 .line_style(LineStyle::new().colour("burlywood"));
18 let mut v = ContinuousView::new().add(l1);
19 v.add_grid(Grid::new(3, 8));
20 Page::single(&v)
21 .save(filename.as_ref())
22 .expect("saving svg");
23}
24
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/line_and_point_svg.rs (line 17)
6fn main() {
7 let l1 = Plot::new(vec![(0., 1.), (2., 1.5), (3., 1.2), (4., 1.1)])
8 .line_style(
9 LineStyle::new()
10 .colour("burlywood")
11 .linejoin(LineJoin::Round),
12 )
13 .point_style(PointStyle::new());
14
15 let v = ContinuousView::new().add(l1);
16 Page::single(&v)
17 .save("line_and_point.svg")
18 .expect("saving svg");
19}
examples/boxplot_svg.rs (line 20)
6fn main() {
7 let b1 = BoxPlot::from_slice(&[1.0, 4.0, 2.0, 3.5, 6.4, 2.5, 7.5, 1.8, 9.6]).label("1");
8 let b2 = BoxPlot::from_slice(&[3.0, 4.3, 2.0, 3.5, 6.9, 4.5, 7.5, 1.8, 10.6])
9 .label("2")
10 .style(&BoxStyle::new().fill("darkolivegreen"));
11
12 let v = CategoricalView::new()
13 .add(b1)
14 .add(b2)
15 .x_label("Experiment")
16 .y_label("y");
17
18 Page::single(&v)
19 .dimensions(400, 300)
20 .save("boxplot.svg")
21 .expect("saving svg");
22}
Additional examples can be found in:
Auto Trait Implementations§
impl<'a> Freeze for Page<'a>
impl<'a> !RefUnwindSafe for Page<'a>
impl<'a> !Send for Page<'a>
impl<'a> !Sync for Page<'a>
impl<'a> Unpin for Page<'a>
impl<'a> !UnwindSafe for Page<'a>
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