Struct Axis

Source
pub struct Axis { /* private fields */ }
Expand description

§Axis

An axis is a reference source for the plot.

Implementations§

Source§

impl Axis

Source

pub fn new() -> Axis

Source

pub fn from_coord(start: Coord, end: Coord) -> Axis

Source

pub fn set_color(&mut self, color: Rgba)

Set the axis color

Source

pub fn set_color_rgb(&mut self, red: f32, green: f32, blue: f32)

Set the axis color

Source

pub fn set_color_rgba(&mut self, red: f32, green: f32, blue: f32, alpha: f32)

Set the axis color

Source

pub fn set_line_width(&mut self, val: f64)

Source

pub fn set_label(&mut self, content: &str)

Source

pub fn set_label_angle(&mut self, angle: f64)

Source

pub fn set_num_ticks(&mut self, val: usize)

Source

pub fn set_positive_tick_length(&mut self, val: f64)

Source

pub fn set_negative_tick_length(&mut self, val: f64)

Source

pub fn set_tick_font_size(&mut self, val: f64)

Source

pub fn set_tick_label_offset(&mut self, hor: f64, ver: f64)

Source

pub fn set_data_range(&mut self, data_min: f64, data_max: f64)

Source

pub fn set_label_offset(&mut self, hor: f64, ver: f64)

Source

pub fn scale_label_offset(&mut self, factor: f64)

Source

pub fn scale_tick_label_offset(&mut self, factor: f64)

Source

pub fn data_min(&self) -> f64

Source

pub fn data_max(&self) -> f64

Source

pub fn mark_coords(&self) -> Vec<Coord>

Source

pub fn compute_marks(&mut self) -> Result<(), Error>

§Compute marks

Marks are used to determine the location of ticks and gridlines.

This method will return a list of evenly spaced marks according to the following method. This assumes that the data range is known, and that know how many marks we want. The latter is determined by a variable, and will be used more of a guide than as the actual number of marks we get in the end.

§Method
  1. Find the orider of magnitude of the difference in the data range. Call this p. 2a. Let min_point be min(data) rounded down to nearest 10^(p - 2). 2b. Let max_point be max(data) rounded up to nearest 10^(p - 2).
  2. mark_distance = (max_point - min_point) / num_labels rounded to nearest 10^(p - 2)
  3. Then, let mark_k = min_point + k*mark_distance, for k = 0 until mark_k is greater or equal to max(data).
  4. Transform between labels in the data framework (the above) and positions in the drawing framework using the data range and axis frame.
  • The user can now set data range, but this function will override it. With this, the output looks nicer, but I assume that when the user puts a data range, the user assumes that this range should be used.
Source

pub fn fit(&mut self, canvas_frame: &Frame)

Fit

This function is called just before draw(), and updates the default w.r.t. user input. and changes above in the hierarchy (canvas -> plot -> figure).

Source

pub fn draw(&self, cr: &Context, fig_rel_height: f64, fig_rel_width: f64)

Draw axis on canvas.

Trait Implementations§

Source§

impl Clone for Axis

Source§

fn clone(&self) -> Axis

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Axis

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Axis

§

impl RefUnwindSafe for Axis

§

impl Send for Axis

§

impl Sync for Axis

§

impl Unpin for Axis

§

impl UnwindSafe for Axis

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.