Struct Figure

Source
pub struct Figure<'a> { /* private fields */ }
Expand description

Creates a figure that will wait to receive samples, then draw them onto the plot.

Implementations§

Source§

impl<'a> Figure<'a>

Source

pub fn new(queue_size: usize) -> Self

Create a figure with default settings.

Source

pub fn new_with_config(config: FigureConfig<'a>, queue_size: usize) -> Self

Create a figure from an existing configuration. Useful if you don’t want to use the builder pattern to initialize a figure from scratch.

Source

pub fn xlim(self, xlim: [f32; 2]) -> Self

Sets the x min and max limits for plotting.

Source

pub fn ylim(self, ylim: [f32; 2]) -> Self

Sets the y min and max limits for plotting.

Source

pub fn xlabel(self, xlabel: &'a str) -> Self

Sets the x label to display.

Source

pub fn ylabel(self, ylabel: &'a str) -> Self

Sets the y label to display.

Source

pub fn color(self, r: u8, g: u8, b: u8) -> Self

Sets the color of the line to draw.

Source

pub fn plot_type(self, plot_type: PlotType) -> Self

Sets the type of plot to generate.

Source

pub fn should_close_window(&mut self) -> bool

Checks events to see if the figure should close or not. Returns true if the window received a close event, false otherwise. In most cases, you don’t need to handle events yourself; use Figure::display() instead.

Source

pub fn plot_xy<T>(&mut self, points: &[(T, T)])
where T: Into<f32> + Copy,

Take an array of 2D points and draw them to the plot. This overrides any samples in the queue.

Source

pub fn plot_y<T>(&mut self, y_coords: &[T])
where T: Into<f32> + Copy,

Takes a series of real samples and draws them onto the plot. This overrides any samples in the queue. The x-axis will be interpolated.

Source

pub fn plot_stream<T>(&mut self, y_coords: &[T])
where T: Into<f32> + Copy,

Takes a series of real samples and draws them onto the plot. Samples received from the stream are appended to the queue and any samples exceeding the queue size are removed. The x-axis will be interpolated.

Source

pub fn plot_complex_stream<T>(&mut self, points: &[Complex<T>])
where T: Into<f32> + Copy,

Takes a slice of complex samples and draws them onto the plot. Samples received from the stream are appended to the queue and any samples exceeding the queue size are removed.

Source

pub fn plot_complex<T>(&mut self, coords: &[Complex<T>])
where T: Into<f32> + Copy,

Takes a slice of complex samples and draws them onto the plot. This overrides any existing samples in the queue.

Source

pub fn display(figure: &mut Figure<'_>, plot_fn: impl FnMut(&mut Figure<'_>))

Hijacks the current thread to run the plotting and event loop.

Trait Implementations§

Source§

impl<'a> Default for Figure<'a>

Source§

fn default() -> Figure<'a>

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

Auto Trait Implementations§

§

impl<'a> !Freeze for Figure<'a>

§

impl<'a> !RefUnwindSafe for Figure<'a>

§

impl<'a> !Send for Figure<'a>

§

impl<'a> !Sync for Figure<'a>

§

impl<'a> Unpin for Figure<'a>

§

impl<'a> !UnwindSafe for Figure<'a>

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.