pub struct Grid {
pub nx: u32,
pub ny: u32,
pub color: String,
}
Expand description
Configuration for the grid on a plot
Supports changing the number of grid lines for the x and y dimensions. Note: for categorical plots, only horizontal lines will be shown.
Fields§
§nx: u32
Number of vertical grid lines (defaults to 3)
ny: u32
Number of horizontal grid lines (defaults to 3)
color: String
Color of the grid lines (defaults to “darkgrey”)
Implementations§
Source§impl Grid
impl Grid
Sourcepub fn new(nx: u32, ny: u32) -> Grid
pub fn new(nx: u32, ny: u32) -> Grid
Create a new grid with nx
vertical and ny
horizontal grid lines
The default colour is “darkgrey”.
Examples found in repository?
examples/with_grid.rs (line 19)
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}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Grid
impl RefUnwindSafe for Grid
impl Send for Grid
impl Sync for Grid
impl Unpin for Grid
impl UnwindSafe for Grid
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