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]
impl Plot
[src]pub fn new(name: impl ToString) -> Self
[src]
pub fn hline(self, hline: HLine) -> Self
[src]
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]
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]
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]
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]
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]
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 symmetrical_x_axis(self, on: bool) -> Self
[src]
Renamed center_x_axis
pub fn symmetrical_y_axis(self, on: bool) -> Self
[src]
Renamed center_y_axis
pub fn center_x_axis(self, on: bool) -> Self
[src]
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]
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]
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]
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]
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]
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]
pub fn show_legend(self, show: bool) -> Self
[src]Whether to show a legend including all named curves. Default: true
.