From 250c582445e9da3e64f6dfe09797c0c876ae3c84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Primo=C5=BE=20Godec?=
Date: Sun, 22 Dec 2019 18:19:36 +0100
Subject: [PATCH] Box Plot: Add box for missing group values
---
Orange/widgets/visualize/owboxplot.py | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/Orange/widgets/visualize/owboxplot.py b/Orange/widgets/visualize/owboxplot.py
index 5811d0244e9..f0ac55b10c1 100644
--- a/Orange/widgets/visualize/owboxplot.py
+++ b/Orange/widgets/visualize/owboxplot.py
@@ -494,20 +494,21 @@ def compute_box_data(self):
self.dist = []
self.conts = contingency.get_contingency(
dataset, attr, self.group_var)
+ group_var_labels = self.group_var.values + [
+ f"Missing {self.group_var.name}"]
if self.is_continuous:
stats, label_texts = [], []
- for i, cont in enumerate(self.conts):
+ for i, cont in enumerate(self.conts.array_with_unknowns):
if np.sum(cont[1]):
stats.append(BoxData(cont, attr, i, self.group_var))
- label_texts.append(self.group_var.values[i])
+ label_texts.append(group_var_labels[i])
self.stats = stats
self.label_txts_all = label_texts
else:
- self.label_txts_all = \
- [v for v, c in zip(
- self.group_var.values + ["Missing values"],
- self.conts.array_with_unknowns)
- if np.sum(c) > 0]
+ self.label_txts_all = [
+ v for v, c in zip(
+ group_var_labels, self.conts.array_with_unknowns)
+ if np.sum(c) > 0]
else:
self.dist = distribution.get_distribution(dataset, attr)
self.conts = []
@@ -1071,7 +1072,7 @@ def strudel(self, dist, group_val_index=None):
cond.append(FilterDiscrete(self.group_var, [group_val_index]))
box.append(FilterGraphicsRectItem(cond, 0, -10, 1, 10))
cum = 0
- values = attr.values + ["Missing values"]
+ values = attr.values + [f"Missing {attr.name}"]
colors = np.vstack((attr.colors, [128, 128, 128]))
for i, v in enumerate(dist):
if v < 1e-6: