From 8be55f10e9d51c035e6c249fe154249f2626de33 Mon Sep 17 00:00:00 2001 From: Johannes Schiffer Date: Fri, 11 Nov 2022 10:27:28 +0100 Subject: [PATCH] Revert "Always draw axis labels at plot borders" This reverts commit 9235e6603366d3b8a8189e2a5fc28c9780b7f54f. --- crates/egui/src/widgets/plot/mod.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/egui/src/widgets/plot/mod.rs b/crates/egui/src/widgets/plot/mod.rs index 79b3a126d..f0b8129e2 100644 --- a/crates/egui/src/widgets/plot/mod.rs +++ b/crates/egui/src/widgets/plot/mod.rs @@ -1547,13 +1547,11 @@ impl PreparedPlot { let galley = ui.painter().layout_no_wrap(text, font_id.clone(), color); let mut text_pos = pos_in_gui + vec2(1.0, -galley.size().y); - // move to border of plot frame - if axis == 0 { - text_pos.y = transform.frame().max[1] - galley.size()[1] - 2.0; - } - if axis == 1 { - text_pos.x = transform.frame().min[0] + 1.0; - } + + // Make sure we see the labels, even if the axis is off-screen: + text_pos[1 - axis] = text_pos[1 - axis] + .at_most(transform.frame().max[1 - axis] - galley.size()[1 - axis] - 2.0) + .at_least(transform.frame().min[1 - axis] + 1.0); shapes.push((Shape::galley(text_pos, galley), text_strength)); }