From 0e7a4fdbfd0b2456307de1bb3ed689d582f395a3 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Tue, 8 Mar 2022 09:50:53 -0500 Subject: [PATCH] Add method to set a Plot's margin (#1308) --- egui/src/widgets/plot/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/egui/src/widgets/plot/mod.rs b/egui/src/widgets/plot/mod.rs index b6f08096..c8fcf2c7 100644 --- a/egui/src/widgets/plot/mod.rs +++ b/egui/src/widgets/plot/mod.rs @@ -287,6 +287,14 @@ impl Plot { self } + /// Set the side margin as a fraction of the plot size. + /// + /// For instance, a value of `0.1` will add 10% space on both sides. + pub fn set_margin_fraction(mut self, margin_fraction: Vec2) -> Self { + self.margin_fraction = margin_fraction; + self + } + /// Whether to allow zooming in the plot by dragging out a box with the secondary mouse button. /// /// Default: `true`.