diff --git a/crates/egui/src/widgets/plot/mod.rs b/crates/egui/src/widgets/plot/mod.rs index 8367d9ab..a31b1dc7 100644 --- a/crates/egui/src/widgets/plot/mod.rs +++ b/crates/egui/src/widgets/plot/mod.rs @@ -1040,6 +1040,11 @@ impl PlotUi { *self.last_screen_transform.bounds() } + /// Set the plot bounds. Can be useful for implementing alternative plot navigation methods. + pub fn set_plot_bounds(&mut self, plot_bounds: PlotBounds) { + self.last_screen_transform.set_bounds(plot_bounds); + } + /// Move the plot bounds. Can be useful for implementing alternative plot navigation methods. pub fn translate_bounds(&mut self, delta_pos: Vec2) { self.last_screen_transform.translate_bounds(delta_pos); diff --git a/crates/egui/src/widgets/plot/transform.rs b/crates/egui/src/widgets/plot/transform.rs index 6abfe261..51c63e89 100644 --- a/crates/egui/src/widgets/plot/transform.rs +++ b/crates/egui/src/widgets/plot/transform.rs @@ -18,6 +18,10 @@ impl PlotBounds { max: [-f64::INFINITY; 2], }; + pub fn from_min_max(min: [f64; 2], max: [f64; 2]) -> Self { + Self { min, max } + } + pub fn min(&self) -> [f64; 2] { self.min }