Struct egui::widgets::plot::Plot [−][src]
pub struct Plot { /* fields omitted */ }
Expand description
A 2D plot, e.g. a graph of a function.
Plot
supports multiple lines and points.
use egui::plot::{Line, Plot, Value, Values};
let sin = (0..1000).map(|i| {
let x = i as f64 * 0.01;
Value::new(x, x.sin())
});
let line = Line::new(Values::from_values_iter(sin));
ui.add(
Plot::new("my_plot").line(line).view_aspect(2.0)
);
Implementations
Add a horizontal line. Can be useful e.g. to show min/max bounds or similar. Always fills the full width of the plot.
Add a vertical line. Can be useful e.g. to show min/max bounds or similar. Always fills the full height of the plot.
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.
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).
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.
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.
Renamed center_x_axis
Renamed center_y_axis
Always keep the x-axis centered. Default: false
.
Always keep the y-axis centered. Default: false
.
Whether to allow zooming in the plot. Default: true
.
Whether to allow dragging in the plot to move the bounds. Default: true
.
Expand bounds to include the given x value.
For instance, to always show the y axis, call plot.include_x(0.0)
.
Expand bounds to include the given y value.
For instance, to always show the x axis, call plot.include_y(0.0)
.
👎 Deprecated: Use Plot::legend
instead
Use Plot::legend
instead
Whether to show a legend including all named items. Default: true
.