Struct Grid

Source
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

Source

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§

Source§

impl Default for Grid

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.