From ef0cf917b1d0aedc4f51bffd68f0e7da2a9e96e2 Mon Sep 17 00:00:00 2001 From: Vesna Tanko Date: Fri, 1 Jul 2016 17:28:26 +0200 Subject: [PATCH] OWBoxPlot: Show corresponding label when ploting discrete variable --- Orange/widgets/visualize/owboxplot.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Orange/widgets/visualize/owboxplot.py b/Orange/widgets/visualize/owboxplot.py index 31cecdc7344..1c9d2198104 100644 --- a/Orange/widgets/visualize/owboxplot.py +++ b/Orange/widgets/visualize/owboxplot.py @@ -397,8 +397,7 @@ def display_changed_disc(self): for row, box in enumerate(self.boxes): y = (-len(self.boxes) + row) * 40 + 10 - self.box_scene.addItem(box) - box.setPos(0, y) + label = self.attr_labels[row] b = label.boundingRect() label.setPos(-b.width() - 10, y - b.height() / 2) @@ -414,15 +413,17 @@ def display_changed_disc(self): self.box_scene.addItem(label) if selected_attribute != selected_grouping: - attr = self.attributes[self.attributes_select[0]][0] - selected_attr = self.dataset.domain[attr] - for label_text, bar_part in zip(selected_attr.values, - box.childItems()): - label = QtGui.QGraphicsSimpleTextItem(label_text) + for text_item, bar_part in zip(box.childItems()[1::2], + box.childItems()[::2]): + label = QtGui.QGraphicsSimpleTextItem( + text_item.toPlainText()) label.setPos(bar_part.boundingRect().x(), y - label.boundingRect().height() - 8) self.box_scene.addItem(label) - + for text_item in box.childItems()[1::2]: + box.removeFromGroup(text_item) + self.box_scene.addItem(box) + box.setPos(0, y) self.box_scene.setSceneRect(-self.label_width - 5, -30 - len(self.boxes) * 40, self.scene_width, len(self.boxes * 40) + 90) @@ -719,6 +720,8 @@ def strudel(self, dist): else: tooltip = "{}: {}".format(attr.values[i], int(dist[i])) rect.setToolTip(tooltip) + text = QtGui.QGraphicsTextItem(attr.values[i]) + box.addToGroup(text) cum += v return box