本文整理汇总了Python中Orange.widgets.visualize.owscatterplotgraph.OWScatterPlotGraph.update_data方法的典型用法代码示例。如果您正苦于以下问题:Python OWScatterPlotGraph.update_data方法的具体用法?Python OWScatterPlotGraph.update_data怎么用?Python OWScatterPlotGraph.update_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.widgets.visualize.owscatterplotgraph.OWScatterPlotGraph
的用法示例。
在下文中一共展示了OWScatterPlotGraph.update_data方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWScatterPlot
# 需要导入模块: from Orange.widgets.visualize.owscatterplotgraph import OWScatterPlotGraph [as 别名]
# 或者: from Orange.widgets.visualize.owscatterplotgraph.OWScatterPlotGraph import update_data [as 别名]
#.........这里部分代码省略.........
model.set_domain(domain)
self.attr_x = self.xy_model[0] if self.xy_model else None
self.attr_y = self.xy_model[1] if len(self.xy_model) >= 2 \
else self.attr_x
self.graph.attr_color = self.data.domain.class_var if domain else None
self.graph.attr_shape = None
self.graph.attr_size = None
self.graph.attr_label = None
def set_attr(self, attr_x, attr_y):
self.attr_x, self.attr_y = attr_x, attr_y
self.update_attr()
def update_attr(self):
self.update_graph()
self.cb_class_density.setEnabled(self.graph.can_draw_density())
self.cb_reg_line.setEnabled(self.graph.can_draw_regresssion_line())
self.send_features()
def update_colors(self):
self._vizrank_color_change()
self.cb_class_density.setEnabled(self.graph.can_draw_density())
def update_density(self):
self.update_graph(reset_view=False)
def update_regression_line(self):
self.update_graph(reset_view=False)
def update_graph(self, reset_view=True, **_):
self.graph.zoomStack = []
if self.graph.data is None:
return
self.graph.update_data(self.attr_x, self.attr_y, reset_view)
def selection_changed(self):
# Store current selection in a setting that is stored in workflow
if isinstance(self.data, SqlTable):
selection = None
elif self.data is not None:
selection = self.graph.get_selection()
else:
selection = None
if selection is not None and len(selection):
self.selection_group = list(zip(selection, self.graph.selection[selection]))
else:
self.selection_group = None
self.commit()
def send_data(self):
# TODO: Implement selection for sql data
def _get_selected():
if not len(selection):
return None
return create_groups_table(data, graph.selection, False, "Group")
def _get_annotated():
if graph.selection is not None and np.max(graph.selection) > 1:
return create_groups_table(data, graph.selection)
else:
return create_annotated_table(data, selection)
graph = self.graph
data = self.data
示例2: OWScatterPlot
# 需要导入模块: from Orange.widgets.visualize.owscatterplotgraph import OWScatterPlotGraph [as 别名]
# 或者: from Orange.widgets.visualize.owscatterplotgraph.OWScatterPlotGraph import update_data [as 别名]
#.........这里部分代码省略.........
self.attr_x = self.xy_model[0] if self.xy_model else None
self.attr_y = self.xy_model[1] if len(self.xy_model) >= 2 \
else self.attr_x
self.graph.attr_color = domain and self.data.domain.class_var or None
self.graph.attr_shape = None
self.graph.attr_size = None
self.graph.attr_label = None
def set_attr(self, attr_x, attr_y):
self.attr_x, self.attr_y = attr_x, attr_y
self.update_attr()
def update_attr(self):
self.prepare_data()
self.update_graph()
self.cb_class_density.setEnabled(self.graph.can_draw_density())
self.cb_reg_line.setEnabled(self.graph.can_draw_regresssion_line())
self.send_features()
def update_colors(self):
self.prepare_data()
self.cb_class_density.setEnabled(self.graph.can_draw_density())
def update_density(self):
self.update_graph(reset_view=False)
def update_regression_line(self):
self.update_graph(reset_view=False)
def update_graph(self, reset_view=True, **_):
self.graph.zoomStack = []
if self.graph.data is None:
return
self.graph.update_data(self.attr_x, self.attr_y, reset_view)
def selection_changed(self):
self.send_data()
@staticmethod
def create_groups_table(data, selection):
if data is None:
return None
names = [var.name for var in data.domain.variables + data.domain.metas]
name = get_next_name(names, "Selection group")
metas = data.domain.metas + (
DiscreteVariable(
name,
["Unselected"] + ["G{}".format(i + 1)
for i in range(np.max(selection))]),
)
domain = Domain(data.domain.attributes, data.domain.class_vars, metas)
table = data.transform(domain)
table.metas[:, len(data.domain.metas):] = \
selection.reshape(len(data), 1)
return table
def send_data(self):
selected = None
selection = None
# TODO: Implement selection for sql data
graph = self.graph
if isinstance(self.data, SqlTable):
selected = self.data
elif self.data is not None:
selection = graph.get_selection()
if len(selection) > 0:
示例3: OWScatterPlot
# 需要导入模块: from Orange.widgets.visualize.owscatterplotgraph import OWScatterPlotGraph [as 别名]
# 或者: from Orange.widgets.visualize.owscatterplotgraph.OWScatterPlotGraph import update_data [as 别名]
#.........这里部分代码省略.........
self.cb_attr_label.addItem(self.icons[var], var.name)
self.attr_x = self.cb_attr_x.itemText(0)
if self.cb_attr_y.count() > 1:
self.attr_y = self.cb_attr_y.itemText(1)
else:
self.attr_y = self.cb_attr_y.itemText(0)
if self.data.domain.class_var:
self.graph.attr_color = self.data.domain.class_var.name
else:
self.graph.attr_color = ""
self.graph.attr_shape = ""
self.graph.attr_size = ""
self.graph.attr_label = ""
def set_attr(self, attr_x, attr_y):
self.attr_x, self.attr_y = attr_x.name, attr_y.name
self.update_attr()
def update_attr(self):
self.update_graph()
self.cb_class_density.setEnabled(self.graph.can_draw_density())
self.send_features()
def update_colors(self):
self.graph.update_colors()
self.cb_class_density.setEnabled(self.graph.can_draw_density())
def update_density(self):
self.update_graph(reset_view=False)
def update_graph(self, reset_view=True, **_):
self.graph.zoomStack = []
if not self.graph.have_data:
return
self.graph.update_data(self.attr_x, self.attr_y, reset_view)
def selection_changed(self):
self.send_data()
def send_data(self):
selected = unselected = None
# TODO: Implement selection for sql data
if isinstance(self.data, SqlTable):
selected = unselected = self.data
elif self.data is not None:
selection = self.graph.get_selection()
if len(selection) == 0:
self.send("Selected Data", None)
self.send("Other Data", self.data)
return
selected = self.data[selection]
unselection = np.full(len(self.data), True, dtype=bool)
unselection[selection] = False
unselected = self.data[unselection]
self.send("Selected Data", selected)
if unselected is None or len(unselected) == 0:
self.send("Other Data", None)
else:
self.send("Other Data", unselected)
def send_features(self):
features = None
if self.attr_x or self.attr_y:
dom = Domain([], metas=(StringVariable(name="feature"),))
features = Table(dom, [[self.attr_x], [self.attr_y]])
features.name = "Features"
self.send("Features", features)
def commit(self):
self.send_data()
self.send_features()
def get_widget_name_extension(self):
if self.data is not None:
return "{} vs {}".format(self.combo_value(self.cb_attr_x),
self.combo_value(self.cb_attr_y))
def send_report(self):
disc_attr = False
if self.data:
domain = self.data.domain
disc_attr = domain[self.attr_x].is_discrete or \
domain[self.attr_y].is_discrete
caption = report.render_items_vert((
("Color", self.combo_value(self.cb_attr_color)),
("Label", self.combo_value(self.cb_attr_label)),
("Shape", self.combo_value(self.cb_attr_shape)),
("Size", self.combo_value(self.cb_attr_size)),
("Jittering", (self.graph.jitter_continuous or disc_attr) and
self.graph.jitter_size)))
self.report_plot()
if caption:
self.report_caption(caption)
def onDeleteWidget(self):
super().onDeleteWidget()
self.graph.plot_widget.getViewBox().deleteLater()
self.graph.plot_widget.clear()
示例4: OWScatterPlot
# 需要导入模块: from Orange.widgets.visualize.owscatterplotgraph import OWScatterPlotGraph [as 别名]
# 或者: from Orange.widgets.visualize.owscatterplotgraph.OWScatterPlotGraph import update_data [as 别名]
#.........这里部分代码省略.........
self.attr_x = self.cb_attr_x.itemText(0)
if self.cb_attr_y.count() > 1:
self.attr_y = self.cb_attr_y.itemText(1)
else:
self.attr_y = self.cb_attr_y.itemText(0)
if self.data.domain.class_var:
self.graph.attr_color = self.data.domain.class_var.name
else:
self.graph.attr_color = ""
self.graph.attr_shape = ""
self.graph.attr_size = ""
self.graph.attr_label = ""
def update_attr(self, attributes=None):
self.update_graph(attributes=attributes)
self.cb_class_density.setEnabled(self.graph.can_draw_density())
self.send_features()
def update_colors(self):
self.graph.update_colors()
self.cb_class_density.setEnabled(self.graph.can_draw_density())
def update_density(self):
self.update_graph(reset_view=False)
def update_graph(self, attributes=None, reset_view=True, **_):
self.graph.zoomStack = []
if attributes and len(attributes) == 2:
self.attr_x, self.attr_y = attributes
if not self.graph.have_data:
return
self.graph.update_data(self.attr_x, self.attr_y, reset_view)
def selection_changed(self):
self.send_data()
def send_data(self):
selected = unselected = None
# TODO: Implement selection for sql data
if isinstance(self.data, SqlTable):
selected = unselected = self.data
elif self.data is not None:
selection = self.graph.get_selection()
selected = self.data[selection]
unselection = np.full(len(self.data), True, dtype=bool)
unselection[selection] = False
unselected = self.data[unselection]
self.send("Selected Data", selected)
self.send("Other Data", unselected)
def send_features(self):
features = None
if self.attr_x or self.attr_y:
dom = Domain([], metas=(StringVariable(name="feature"),))
features = Table(dom, [[self.attr_x], [self.attr_y]])
features.name = "Features"
self.send("Features", features)
def commit(self):
self.send_data()
self.send_features()
def set_colors(self):
dlg = self.create_color_dialog()
示例5: OWScatterPlot
# 需要导入模块: from Orange.widgets.visualize.owscatterplotgraph import OWScatterPlotGraph [as 别名]
# 或者: from Orange.widgets.visualize.owscatterplotgraph.OWScatterPlotGraph import update_data [as 别名]
#.........这里部分代码省略.........
return
for var in self.data.domain.metas:
self.cb_attr_label.addItem(self.icons[var], var.name)
for attr in self.data.domain.variables:
self.cb_attr_x.addItem(self.icons[attr], attr.name)
self.cb_attr_y.addItem(self.icons[attr], attr.name)
self.cb_attr_color.addItem(self.icons[attr], attr.name)
if attr.is_discrete:
self.cb_attr_shape.addItem(self.icons[attr], attr.name)
else:
self.cb_attr_size.addItem(self.icons[attr], attr.name)
self.cb_attr_label.addItem(self.icons[attr], attr.name)
self.attr_x = self.cb_attr_x.itemText(0)
if self.cb_attr_y.count() > 1:
self.attr_y = self.cb_attr_y.itemText(1)
else:
self.attr_y = self.cb_attr_y.itemText(0)
if self.data.domain.class_var:
self.graph.attr_color = self.data.domain.class_var.name
else:
self.graph.attr_color = ""
self.graph.attr_shape = ""
self.graph.attr_size = ""
self.graph.attr_label = ""
def major_graph_update(self, attributes=None, inside_colors=None, **args):
self.update_graph(attributes, inside_colors, **args)
def update_graph(self, attributes=None, inside_colors=None, **_):
self.graph.zoomStack = []
if not self.graph.have_data:
return
if attributes and len(attributes) == 2:
self.attr_x, self.attr_y = attributes
self.graph.update_data(self.attr_x, self.attr_y)
def saveSettings(self):
OWWidget.saveSettings(self)
# self.vizrank.saveSettings()
def selection_changed(self):
self.commit()
def commit(self):
selected = unselected = None
# TODO: Implement selection for sql data
if isinstance(self.data, SqlTable):
selected = unselected = self.data
elif self.data is not None:
selection = self.graph.get_selection()
selected = self.data[selection]
unselection = np.full(len(self.data), True, dtype=bool)
unselection[selection] = False
unselected = self.data[unselection]
self.send("Selected Data", selected)
self.send("Other Data", unselected)
def set_colors(self):
dlg = self.create_color_dialog()
if dlg.exec_():
self.color_settings = dlg.getColorSchemas()
self.selected_schema_index = dlg.selectedSchemaIndex
self.graph.continuous_palette = dlg.getContinuousPalette("contPalette")
self.graph.discrete_palette = dlg.getDiscretePalette("discPalette")
self.update_graph()
def create_color_dialog(self):
c = ColorPaletteDlg(self, "Color Palette")
c.createDiscretePalette("discPalette", "Discrete Palette")
c.createContinuousPalette("contPalette", "Continuous Palette")
c.setColorSchemas(self.color_settings, self.selected_schema_index)
return c
def closeEvent(self, ce):
# self.vizrank.close()
super().closeEvent(ce)
def sendReport(self):
self.startReport(
"%s [%s - %s]" % (self.windowTitle(), self.attr_x, self.attr_y))
self.reportSettings(
"Visualized attributes",
[("X", self.attr_x),
("Y", self.attr_y),
self.graph.attr_color and ("Color", self.graph.attr_color),
self.graph.attr_label and ("Label", self.graph.attr_label),
self.graph.attr_shape and ("Shape", self.graph.attr_shape),
self.graph.attr_size and ("Size", self.graph.attr_size)])
self.reportSettings(
"Settings",
[("Symbol size", self.graph.point_width),
("Opacity", self.graph.alpha_value),
("Jittering", self.graph.jitter_size),
("Jitter continuous attributes",
gui.YesNo[self.graph.jitter_continuous])])
self.reportSection("Graph")
self.reportImage(self.graph.save_to_file, QSize(400, 400))
示例6: OWScatterPlot
# 需要导入模块: from Orange.widgets.visualize.owscatterplotgraph import OWScatterPlotGraph [as 别名]
# 或者: from Orange.widgets.visualize.owscatterplotgraph.OWScatterPlotGraph import update_data [as 别名]
#.........这里部分代码省略.........
for attr in self.data.domain.variables:
self.cb_attr_x.addItem(self.icons[attr], attr.name)
self.cb_attr_y.addItem(self.icons[attr], attr.name)
self.cb_attr_color.addItem(self.icons[attr], attr.name)
if isinstance(attr, DiscreteVariable):
self.cb_attr_shape.addItem(self.icons[attr], attr.name)
else:
self.cb_attr_size.addItem(self.icons[attr], attr.name)
self.cb_attr_label.addItem(self.icons[attr], attr.name)
self.attr_x = self.cb_attr_x.itemText(0)
if self.cb_attr_y.count() > 1:
self.attr_y = self.cb_attr_y.itemText(1)
else:
self.attr_y = self.cb_attr_y.itemText(0)
if self.data.domain.class_var:
self.graph.attr_color = self.data.domain.class_var.name
else:
self.graph.attr_color = ""
self.graph.attr_shape = ""
self.graph.attr_size = ""
self.graph.attr_label = ""
def major_graph_update(self, attributes=None, inside_colors=None, **args):
self.update_graph(attributes, inside_colors, **args)
def update_graph(self, attributes=None, inside_colors=None, **_):
self.graph.zoomStack = []
if not self.graph.have_data:
return
if attributes and len(attributes) == 2:
self.attr_x, self.attr_y = attributes
self.graph.update_data(self.attr_x, self.attr_y)
def saveSettings(self):
OWWidget.saveSettings(self)
# self.vizrank.saveSettings()
"""
def auto_selection_changed(self):
self.zoom_select_toolbar.buttons[OWPlotGUI.SendSelection].setEnabled(
not self.auto_send_selection)
if self.auto_send_selection:
self.send_selection()
"""
def selection_changed(self):
if self.auto_send_selection:
self.send_selection()
else:
self.selection_dirty = True
def send_selection(self):
self.selection_dirty = False
selection = self.graph.get_selection()
selected = self.data[selection]
unselection = np.full(len(self.data), True, dtype=bool)
unselection[selection] = False
unselected = self.data[unselection]
self.send("Selected Data", selected)
self.send("Other Data", unselected)
def set_colors(self):
dlg = self.create_color_dialog()
if dlg.exec_():
self.color_settings = dlg.getColorSchemas()
self.selected_schema_index = dlg.selectedSchemaIndex