Skip to content

Commit

Permalink
Merge pull request #3439 from VesnaT/fix_scatterplot
Browse files Browse the repository at this point in the history
[FIX] Scatter Plot: Replot when input Features
  • Loading branch information
lanzagar authored Dec 4, 2018
2 parents 1602d56 + 242dad1 commit 179d1ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Orange/widgets/visualize/owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,11 @@ def handleNewSignals(self):
self.data.domain is not None and \
all(attr in self.data.domain for attr
in self.attribute_selection_list):
self.attr_x = self.attribute_selection_list[0]
self.attr_y = self.attribute_selection_list[1]
self.attribute_selection_list = None
super().handleNewSignals()
self.set_attr(self.attribute_selection_list[0],
self.attribute_selection_list[1])
self.attribute_selection_list = None
else:
super().handleNewSignals()
self._vizrank_color_change()
self.cb_reg_line.setEnabled(self.can_draw_regresssion_line())

Expand All @@ -426,8 +427,9 @@ def set_shown_attributes(self, attributes):
self.attribute_selection_list = None

def set_attr(self, attr_x, attr_y):
self.attr_x, self.attr_y = attr_x, attr_y
self.attr_changed()
if attr_x != self.attr_x or attr_y != self.attr_y:
self.attr_x, self.attr_y = attr_x, attr_y
self.attr_changed()

def attr_changed(self):
self.cb_reg_line.setEnabled(self.can_draw_regresssion_line())
Expand Down
6 changes: 6 additions & 0 deletions Orange/widgets/visualize/tests/test_owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,16 @@ def test_features_and_no_data(self):
def test_features_and_data(self):
data = Table("iris")
self.send_signal(self.widget.Inputs.data, data)
x, y = self.widget.graph.scatterplot_item.getData()
np.testing.assert_array_equal(x, data.X[:, 0])
np.testing.assert_array_equal(y, data.X[:, 1])
self.send_signal(self.widget.Inputs.features,
AttributeList(data.domain[2:]))
self.assertIs(self.widget.attr_x, data.domain[2])
self.assertIs(self.widget.attr_y, data.domain[3])
x, y = self.widget.graph.scatterplot_item.getData()
np.testing.assert_array_equal(x, data.X[:, 2])
np.testing.assert_array_equal(y, data.X[:, 3])

def test_output_features(self):
data = Table("iris")
Expand Down

0 comments on commit 179d1ed

Please sign in to comment.