pub struct Axis { /* private fields */ }
Expand description
§Axis
An axis is a reference source for the plot.
Implementations§
Source§impl Axis
impl Axis
pub fn new() -> Axis
pub fn from_coord(start: Coord, end: Coord) -> Axis
Sourcepub fn set_color_rgb(&mut self, red: f32, green: f32, blue: f32)
pub fn set_color_rgb(&mut self, red: f32, green: f32, blue: f32)
Set the axis color
Sourcepub fn set_color_rgba(&mut self, red: f32, green: f32, blue: f32, alpha: f32)
pub fn set_color_rgba(&mut self, red: f32, green: f32, blue: f32, alpha: f32)
Set the axis color
pub fn set_line_width(&mut self, val: f64)
pub fn set_label(&mut self, content: &str)
pub fn set_label_angle(&mut self, angle: f64)
pub fn set_num_ticks(&mut self, val: usize)
pub fn set_positive_tick_length(&mut self, val: f64)
pub fn set_negative_tick_length(&mut self, val: f64)
pub fn set_tick_font_size(&mut self, val: f64)
pub fn set_tick_label_offset(&mut self, hor: f64, ver: f64)
pub fn set_data_range(&mut self, data_min: f64, data_max: f64)
pub fn set_label_offset(&mut self, hor: f64, ver: f64)
pub fn scale_label_offset(&mut self, factor: f64)
pub fn scale_tick_label_offset(&mut self, factor: f64)
pub fn data_min(&self) -> f64
pub fn data_max(&self) -> f64
pub fn mark_coords(&self) -> Vec<Coord>
Sourcepub fn compute_marks(&mut self) -> Result<(), Error>
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
- 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).
- mark_distance = (max_point - min_point) / num_labels rounded to nearest 10^(p - 2)
- Then, let mark_k = min_point + k*mark_distance, for k = 0 until mark_k is greater or equal to max(data).
- 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.
Trait Implementations§
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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