Skip to content

Commit

Permalink
modified: src/histoer/histo1d/histogram1d.rs
Browse files Browse the repository at this point in the history
	modified:   src/histoer/histo1d/keybinds.rs
  • Loading branch information
alconley committed Jan 17, 2025
1 parent 8b62f85 commit 97c4f78
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/histoer/histo1d/histogram1d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/histoer/histo1d/keybinds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 97c4f78

Please sign in to comment.