pub struct Plot<'a> { /* private fields */ }Expand description
The plot builder. Add series, then call show with the icon cache and a
PlotState.
let data: Vec<[f64; 2]> = (0..100).map(|i| [i as f64 * 0.1, (i as f64 * 0.1).sin()]).collect();
let mut state = PlotState::default();
let response = Plot::new("signal")
.title("Signal")
.x_label("t (s)")
.y_label("V")
.height(280.0)
.series(Series::line("sin", &data))
.series(Series::scatter("samples", &data[..10]))
.show(ui, &mut icons, &mut state);
if let Some(hover) = response.hovered {
let _ = hover.point;
}Implementations§
Source§impl<'a> Plot<'a>
impl<'a> Plot<'a>
Sourcepub fn measurement_mode(self, mode: MeasurementMode) -> Self
pub fn measurement_mode(self, mode: MeasurementMode) -> Self
Set the area tool mode: rectangle or curve-vs-chord.
Sourcepub fn measurement_area_style(self, style: MeasurementAreaStyle) -> Self
pub fn measurement_area_style(self, style: MeasurementAreaStyle) -> Self
Set which area the curve-segment label emphasizes.
Sourcepub fn measurement_snap_radius(self, radius: f32) -> Self
pub fn measurement_snap_radius(self, radius: f32) -> Self
Set the measurement snap radius in points.
Sourcepub fn measurement_labels(self, show: bool) -> Self
pub fn measurement_labels(self, show: bool) -> Self
Show or hide measurement labels.
Sourcepub fn config(self, config: PlotConfig) -> Self
pub fn config(self, config: PlotConfig) -> Self
Replace the whole appearance (text, sizes, colors, axes, grid, legend, and per-series styles). Call it first; the other builder methods edit it.
Sourcepub fn current_config(&self) -> &PlotConfig
pub fn current_config(&self) -> &PlotConfig
The current appearance.
Sourcepub fn series_names(&self) -> Vec<String>
pub fn series_names(&self) -> Vec<String>
The names of the series, in drawing order (for a settings dialog).
Sourcepub fn x_limits(self, min: Option<f64>, max: Option<f64>) -> Self
pub fn x_limits(self, min: Option<f64>, max: Option<f64>) -> Self
Fixed x limits in data units (None keeps that side automatic).
Sourcepub fn y_limits(self, min: Option<f64>, max: Option<f64>) -> Self
pub fn y_limits(self, min: Option<f64>, max: Option<f64>) -> Self
Fixed y limits in data units (None keeps that side automatic).
Show a settings button in the toolbar; see PlotResponse::settings_requested.
Show an SVG/PNG export menu in the toolbar; see
PlotResponse::export_requested.
Sourcepub fn series(self, series: Series<'a>) -> Self
pub fn series(self, series: Series<'a>) -> Self
Add a series. Series draw in order; the palette color follows the order too.
Sourcepub fn fit(self, kind: FitKind, data: &[[f64; 2]]) -> Self
pub fn fit(self, kind: FitKind, data: &[[f64; 2]]) -> Self
Fit kind to data and add the dashed curve, named with its equation and R².
Nothing is added when the fit fails (too few points, singular system).
Sourcepub fn x_label(self, label: impl Into<String>) -> Self
pub fn x_label(self, label: impl Into<String>) -> Self
The x axis label (also used in the hover popup).
Sourcepub fn y2_label(self, label: impl Into<String>) -> Self
pub fn y2_label(self, label: impl Into<String>) -> Self
The right y axis title, drawn vertically (the axis shows when a series uses
YAxis::Right).
Sourcepub fn y2_limits(self, min: Option<f64>, max: Option<f64>) -> Self
pub fn y2_limits(self, min: Option<f64>, max: Option<f64>) -> Self
Fixed right y limits in data units (None keeps that side automatic).
Sourcepub fn height(self, height: f32) -> Self
pub fn height(self, height: f32) -> Self
Fixed height; fills the available height otherwise (320 pt in scroll areas).
Sourcepub fn legend(self, legend: LegendPosition) -> Self
pub fn legend(self, legend: LegendPosition) -> Self
Legend corner, or LegendPosition::Hidden.
Sourcepub fn legend_hover(self, config: LegendHoverConfig) -> Self
pub fn legend_hover(self, config: LegendHoverConfig) -> Self
Replace the legend hover animation settings.
Sourcepub fn legend_animation(self, animation: LegendAnimation) -> Self
pub fn legend_animation(self, animation: LegendAnimation) -> Self
The animation played while the pointer rests on a legend row (enabled by default).
Sourcepub fn series_all(self, series: impl IntoIterator<Item = Series<'a>>) -> Self
pub fn series_all(self, series: impl IntoIterator<Item = Series<'a>>) -> Self
Add every series from an iterator, for multi-series families such as box plots.
Sourcepub fn direction(self, config: DirectionArrowConfig) -> Self
pub fn direction(self, config: DirectionArrowConfig) -> Self
Replace the direction-arrow settings.
Sourcepub fn direction_arrow(self, show: bool) -> Self
pub fn direction_arrow(self, show: bool) -> Self
Show or hide the direction arrow beside the newest point of line-like series.
Sourcepub fn direction_points(self, points: usize) -> Self
pub fn direction_points(self, points: usize) -> Self
How many trailing samples measure the direction arrow (5 by default).
Sourcepub fn radar(self, config: RadarConfig) -> Self
pub fn radar(self, config: RadarConfig) -> Self
Replace the radar layout (labels, maximum, rings, fill).
Sourcepub fn gauge(self, config: GaugeConfig) -> Self
pub fn gauge(self, config: GaugeConfig) -> Self
Replace the gauge layout.
Sourcepub fn heatmap(self, config: HeatmapConfig) -> Self
pub fn heatmap(self, config: HeatmapConfig) -> Self
Replace the heatmap layout.
Sourcepub fn waterfall(self, config: WaterfallConfig) -> Self
pub fn waterfall(self, config: WaterfallConfig) -> Self
Replace the waterfall layout.
Sourcepub fn toolbar(self, toolbar: bool) -> Self
pub fn toolbar(self, toolbar: bool) -> Self
Show the tool buttons in the top-right corner (on by default).
Source§impl Plot<'_>
impl Plot<'_>
Sourcepub fn from_dataset(data: &Dataset) -> DatasetPlot<'_>
pub fn from_dataset(data: &Dataset) -> DatasetPlot<'_>
Start a plot bound to dataset columns.
Source§impl Plot<'_>
impl Plot<'_>
Sourcepub fn to_svg(
&self,
ctx: &Context,
state: &PlotState,
options: &ExportOptions,
) -> String
pub fn to_svg( &self, ctx: &Context, state: &PlotState, options: &ExportOptions, ) -> String
The plot as a standalone SVG document: the same view, colors, legend, and selection as on screen, without the toolbar and hover popup.
Trait Implementations§
Source§impl IconComponent for Plot<'_>
impl IconComponent for Plot<'_>
Source§type Output = PlotResponse
type Output = PlotResponse
Auto Trait Implementations§
impl<'a> Forget for Plot<'a>
impl<'a> Freeze for Plot<'a>where
NonZero<u64>: Freeze,
*const u8 is !null: Freeze,
PhantomData<Series<'a>>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
PhantomData<SeriesStyle>: Freeze,
impl<'a> Move for Plot<'a>
impl<'a> RefUnwindSafe for Plot<'a>where
NonZero<u64>: RefUnwindSafe,
Vec<[f64; 2]>: RefUnwindSafe,
Vec<f64>: RefUnwindSafe,
Vec<[f64; 5]>: RefUnwindSafe,
Vec<[f64; 3]>: RefUnwindSafe,
impl<'a> Send for Plot<'a>
impl<'a> Sync for Plot<'a>
impl<'a> Unpin for Plot<'a>
impl<'a> UnsafeUnpin for Plot<'a>where
NonZeroU64Inner: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Series<'a>>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<SeriesStyle>: UnsafeUnpin,
impl<'a> UnwindSafe for Plot<'a>where
NonZero<u64>: UnwindSafe,
RawVecInner: UnwindSafe,
&'a [[f64; 2]]: UnwindSafe,
Vec<[f64; 2]>: UnwindSafe,
&'a [f64]: UnwindSafe,
Vec<f64>: UnwindSafe,
&'a [[f64; 5]]: UnwindSafe,
Vec<[f64; 5]>: UnwindSafe,
&'a [[f64; 3]]: UnwindSafe,
Vec<[f64; 3]>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more