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
impl PlotUi
pub fn ctx(&self) -> &Context
sourcepub fn plot_bounds(&self) -> PlotBounds
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.
sourcepub fn set_plot_bounds(&mut self, plot_bounds: PlotBounds)
pub fn set_plot_bounds(&mut self, plot_bounds: PlotBounds)
Set the plot bounds. Can be useful for implementing alternative plot navigation methods.
sourcepub fn translate_bounds(&mut self, delta_pos: Vec2)
pub fn translate_bounds(&mut self, delta_pos: Vec2)
Move the plot bounds. Can be useful for implementing alternative plot navigation methods.
sourcepub fn auto_bounds(&self) -> Vec2b
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.
sourcepub fn set_auto_bounds(&mut self, auto_bounds: Vec2b)
pub fn set_auto_bounds(&mut self, auto_bounds: Vec2b)
Set the auto-bounds mode for the plot axes.
sourcepub fn zoom_bounds(&mut self, zoom_factor: Vec2, center: PlotPoint)
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.
sourcepub fn zoom_bounds_around_hovered(&mut self, zoom_factor: Vec2)
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.
sourcepub fn pointer_coordinate(&self) -> Option<PlotPoint>
pub fn pointer_coordinate(&self) -> Option<PlotPoint>
The pointer position in plot coordinates. Independent of whether the pointer is in the plot area.
sourcepub fn pointer_coordinate_drag_delta(&self) -> Vec2
pub fn pointer_coordinate_drag_delta(&self) -> Vec2
The pointer drag delta in plot coordinates.
sourcepub fn transform(&self) -> &PlotTransform
pub fn transform(&self) -> &PlotTransform
Read the transform between plot coordinates and screen coordinates.
sourcepub fn screen_from_plot(&self, position: PlotPoint) -> Pos2
pub fn screen_from_plot(&self, position: PlotPoint) -> Pos2
Transform the plot coordinates to screen coordinates.
sourcepub fn plot_from_screen(&self, position: Pos2) -> PlotPoint
pub fn plot_from_screen(&self, position: Pos2) -> PlotPoint
Transform the screen coordinates to plot coordinates.
sourcepub fn hline(&mut self, hline: HLine)
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.