Struct egui::widgets::plot::Plot[][src]

pub struct Plot { /* fields omitted */ }

A 2D plot, e.g. a graph of a function.

Plot supports multiple curves.

use egui::plot::{Curve, Plot, Value};
let sin = (0..1000).map(|i| {
    let x = i as f64 * 0.01;
    Value::new(x, x.sin())
});
let curve = Curve::from_values_iter(sin);
ui.add(
    Plot::new("Test Plot").curve(curve).view_aspect(2.0)
);

Implementations

impl Plot[src]

pub fn new(name: impl ToString) -> Self[src]

pub fn curve(self, curve: Curve) -> Self[src]

Add a data curve. You can add multiple curves.

pub fn hline(self, hline: HLine) -> Self[src]

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

pub fn vline(self, vline: VLine) -> Self[src]

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

pub fn data_aspect(self, data_aspect: f32) -> Self[src]

width / height ratio of the data. For instance, it can be useful to set this to 1.0 for when the two axes show the same unit. By default the plot window’s aspect ratio is used.

pub fn view_aspect(self, view_aspect: f32) -> Self[src]

width / height ratio of the plot region. By default no fixed aspect ratio is set (and width/height will fill the ui it is in).

pub fn width(self, width: f32) -> Self[src]

Width of plot. By default a plot will fill the ui it is in. If you set Self::view_aspect, the width can be calculated from the height.

pub fn height(self, height: f32) -> Self[src]

Height of plot. By default a plot will fill the ui it is in. If you set Self::view_aspect, the height can be calculated from the width.

pub fn min_size(self, min_size: Vec2) -> Self[src]

Minimum size of the plot view.

pub fn show_x(self, show_x: bool) -> Self[src]

Show the x-value (e.g. when hovering). Default: true.

pub fn show_y(self, show_y: bool) -> Self[src]

Show the y-value (e.g. when hovering). Default: true.

pub fn symmetrical_x_axis(self, on: bool) -> Self[src]

👎 Deprecated:

Renamed center_x_axis

pub fn symmetrical_y_axis(self, on: bool) -> Self[src]

👎 Deprecated:

Renamed center_y_axis

pub fn center_x_axis(self, on: bool) -> Self[src]

Always keep the x-axis centered. Default: false.

pub fn center_y_axis(self, on: bool) -> Self[src]

Always keep the y-axis centered. Default: false.

pub fn allow_zoom(self, on: bool) -> Self[src]

Whether to allow zooming in the plot. Default: true.

pub fn allow_drag(self, on: bool) -> Self[src]

Whether to allow dragging in the plot to move the bounds. Default: true.

pub fn include_x(self, x: impl Into<f64>) -> Self[src]

Expand bounds to include the given x value. For instance, to always show the y axis, call plot.include_x(0.0).

pub fn include_y(self, y: impl Into<f64>) -> Self[src]

Expand bounds to include the given y value. For instance, to always show the x axis, call plot.include_y(0.0).

pub fn show_legend(self, show: bool) -> Self[src]

Whether to show a legend including all named curves. Default: true.

Trait Implementations

impl Widget for Plot[src]

fn ui(self, ui: &mut Ui) -> Response[src]

Allocate space, interact, paint, and return a Response.

Auto Trait Implementations

impl !RefUnwindSafe for Plot

impl !Send for Plot

impl !Sync for Plot

impl Unpin for Plot

impl !UnwindSafe for Plot

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.