diff --git a/src/histoer/histo1d/histogram1d.rs b/src/histoer/histo1d/histogram1d.rs index e22d0b5..8265e50 100644 --- a/src/histoer/histo1d/histogram1d.rs +++ b/src/histoer/histo1d/histogram1d.rs @@ -246,6 +246,7 @@ impl Histogram { if self.plot_settings.egui_settings.reset_axis { self.plot_settings.egui_settings.reset_axis_lims(plot_ui); + self.plot_settings.egui_settings.reset_axis = false; } else { self.limit_scrolling(plot_ui); } @@ -275,6 +276,19 @@ impl Histogram { let y_max = self.bins.iter().max().cloned().unwrap_or(0) as f64; let y_min = self.bins.iter().min().cloned().unwrap_or(0) as f64; + // account for log y + let y_min = if self.plot_settings.egui_settings.log_y { + 0.01 + } else { + y_min + }; + + let y_max = if self.plot_settings.egui_settings.log_y { + y_max.log10().max(0.0001) + } else { + y_max + }; + if current_x_min == -1.0 && current_x_max == 1.0 && current_y_min == 0.0 @@ -293,6 +307,12 @@ impl Histogram { let new_y_min = current_y_min.max(y_min * 1.1); let new_y_max = current_y_max.min(y_max * 1.1); + let new_y_min = if self.plot_settings.egui_settings.log_y { + 0.01 + } else { + new_y_min + }; + if new_x_min != current_x_min || new_x_max != current_x_max || new_y_min != current_y_min diff --git a/src/histoer/histo1d/keybinds.rs b/src/histoer/histo1d/keybinds.rs index 35832be..ebfb4b4 100644 --- a/src/histoer/histo1d/keybinds.rs +++ b/src/histoer/histo1d/keybinds.rs @@ -59,6 +59,7 @@ impl Histogram { if ui.input(|i| i.key_pressed(egui::Key::L)) { self.plot_settings.egui_settings.log_y = !self.plot_settings.egui_settings.log_y; + self.plot_settings.egui_settings.reset_axis = true; } if ui.input(|i| i.key_pressed(egui::Key::O)) {