Struct egui_plot::PlotUi

source ·
pub struct PlotUi { /* private fields */ }
Expand description

Provides methods to interact with a plot while building it. It is the single argument of the closure provided to Plot::show. See Plot for an example of how to use it.

Implementations§

source§

impl PlotUi

source

pub fn ctx(&self) -> &Context

source

pub fn plot_bounds(&self) -> PlotBounds

The plot bounds as they were in the last frame. If called on the first frame and the bounds were not further specified in the plot builder, this will return bounds centered on the origin. The bounds do not change until the plot is drawn.

source

pub fn set_plot_bounds(&mut self, plot_bounds: PlotBounds)

Set the plot bounds. Can be useful for implementing alternative plot navigation methods.

source

pub fn translate_bounds(&mut self, delta_pos: Vec2)

Move the plot bounds. Can be useful for implementing alternative plot navigation methods.

source

pub fn auto_bounds(&self) -> Vec2b

Whether the plot axes were in auto-bounds mode in the last frame. If called on the first frame, this is the Plot’s default auto-bounds mode.

source

pub fn set_auto_bounds(&mut self, auto_bounds: Vec2b)

Set the auto-bounds mode for the plot axes.

source

pub fn response(&self) -> &Response

Can be used to check if the plot was hovered or clicked.

source

pub fn zoom_bounds(&mut self, zoom_factor: Vec2, center: PlotPoint)

Scale the plot bounds around a position in screen coordinates.

Can be useful for implementing alternative plot navigation methods.

The plot bounds are divided by zoom_factor, therefore:

  • zoom_factor < 1.0 zooms out, i.e., increases the visible range to show more data.
  • zoom_factor > 1.0 zooms in, i.e., reduces the visible range to show more detail.
source

pub fn zoom_bounds_around_hovered(&mut self, zoom_factor: Vec2)

Scale the plot bounds around the hovered position, if any.

Can be useful for implementing alternative plot navigation methods.

The plot bounds are divided by zoom_factor, therefore:

  • zoom_factor < 1.0 zooms out, i.e., increases the visible range to show more data.
  • zoom_factor > 1.0 zooms in, i.e., reduces the visible range to show more detail.
source

pub fn pointer_coordinate(&self) -> Option<PlotPoint>

The pointer position in plot coordinates. Independent of whether the pointer is in the plot area.

source

pub fn pointer_coordinate_drag_delta(&self) -> Vec2

The pointer drag delta in plot coordinates.

source

pub fn transform(&self) -> &PlotTransform

Read the transform between plot coordinates and screen coordinates.

source

pub fn screen_from_plot(&self, position: PlotPoint) -> Pos2

Transform the plot coordinates to screen coordinates.

source

pub fn plot_from_screen(&self, position: Pos2) -> PlotPoint

Transform the screen coordinates to plot coordinates.

source

pub fn add(&mut self, item: impl PlotItem + 'static)

Add an arbitrary item.

source

pub fn line(&mut self, line: Line)

Add a data line.

source

pub fn polygon(&mut self, polygon: Polygon)

Add a polygon. The polygon has to be convex.

source

pub fn text(&mut self, text: Text)

Add a text.

source

pub fn points(&mut self, points: Points)

Add data points.

source

pub fn arrows(&mut self, arrows: Arrows)

Add arrows.

source

pub fn image(&mut self, image: PlotImage)

Add an image.

source

pub fn hline(&mut self, hline: HLine)

Add a horizontal line. Can be useful e.g. to show min/max bounds or similar. Always fills the full width of the plot.

source

pub fn vline(&mut self, vline: VLine)

Add a vertical line. Can be useful e.g. to show min/max bounds or similar. Always fills the full height of the plot.

source

pub fn box_plot(&mut self, box_plot: BoxPlot)

Add a box plot diagram.

source

pub fn bar_chart(&mut self, chart: BarChart)

Add a bar chart.

Auto Trait Implementations§

§

impl Freeze for PlotUi

§

impl !RefUnwindSafe for PlotUi

§

impl !Send for PlotUi

§

impl !Sync for PlotUi

§

impl Unpin for PlotUi

§

impl !UnwindSafe for PlotUi

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>,

§

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>,

§

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.