Skip to content

Commit

Permalink
Setting y-min to 0 in relevant xan plot scenarios
Browse files Browse the repository at this point in the history
Fix #348
  • Loading branch information
Yomguithereal committed Jan 27, 2025
1 parent 4d92af0 commit 4ffa387
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/cmd/plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
}
if let Some(y_min) = flag_y_min {
series.set_y_min(y_min);
} else {
// If y domain is positive, we set min to 0
if matches!(series.y_domain(), Some((y_min, _)) if y_min.as_float() > 0.0) {
series.set_y_min(DynamicNumber::Integer(0));
}
}
if let Some(y_max) = flag_y_max {
series.set_y_max(y_max);
Expand Down
3 changes: 2 additions & 1 deletion src/scales.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl Conversion {
}

#[derive(Debug)]
struct Scale {
pub struct Scale {
input_domain: (f64, f64),
output_range: (f64, f64),
conversion: Conversion,
Expand Down Expand Up @@ -325,6 +325,7 @@ mod tests {
ticks(0.0, 10.0, 10),
[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
);
assert_eq!(ticks(-5.0, 5.0, 3), vec![-5.0, 0.0, 5.0]);
}

#[test]
Expand Down

0 comments on commit 4ffa387

Please sign in to comment.