Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] OWBoxPlot: Show corresponding label when ploting discrete variable #1400

Merged
merged 1 commit into from
Jul 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions Orange/widgets/visualize/owboxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand Down