Skip to content

Commit 7ebebb8

Browse files
author
Tobias van Driessel
committed
fix overlap when max lower than upper or min higher than lower
1 parent 46fcbac commit 7ebebb8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/element/boxplot_outliers.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,23 @@ impl BoxplotData {
8484
assert!(minimum.is_some());
8585
assert!(maximum.is_some());
8686

87+
let mut minimum = minimum.unwrap();
88+
let mut maximum = maximum.unwrap();
89+
90+
//Make sure whiskers don't overlap with body of the upper-median-lower
91+
if minimum > lower {
92+
minimum = lower;
93+
}
94+
if maximum < upper {
95+
maximum = upper;
96+
}
97+
8798
Self {
88-
minimum: minimum.unwrap(),
99+
minimum,
89100
lower_quartile: lower,
90101
median,
91102
upper_quartile: upper,
92-
maximum: maximum.unwrap(),
103+
maximum,
93104
outliers
94105
}
95106
}

0 commit comments

Comments
 (0)