本文整理汇总了Python中Orange.widgets.utils.plot.OWPlot.event方法的典型用法代码示例。如果您正苦于以下问题:Python OWPlot.event方法的具体用法?Python OWPlot.event怎么用?Python OWPlot.event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.widgets.utils.plot.OWPlot
的用法示例。
在下文中一共展示了OWPlot.event方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: event
# 需要导入模块: from Orange.widgets.utils.plot import OWPlot [as 别名]
# 或者: from Orange.widgets.utils.plot.OWPlot import event [as 别名]
def event(self, ev):
if ev.type() == QEvent.ToolTip:
x = self.inv_transform(xBottom, ev.pos().x())
y = self.inv_transform(yLeft, ev.pos().y())
canvas_position = self.mapToScene(ev.pos())
x_float = self.inv_transform(xBottom, canvas_position.x())
contact, (index, pos) = self.testArrowContact(int(round(x_float)), canvas_position.x(), canvas_position.y())
if contact:
attr = self.data_domain[self.attributes[index]]
if isinstance(attr, ContinuousVariable):
condition = self.selection_conditions.get(attr.name, [0, 1])
val = self.attr_values[attr.name][0] + condition[pos] * (
self.attr_values[attr.name][1] - self.attr_values[attr.name][0]
)
str_val = attr.name + "= %%.%df" % attr.number_of_decimals % val
QToolTip.showText(ev.globalPos(), str_val)
else:
for curve in self.items():
if (
type(curve) == PolygonCurve
and curve.boundingRect().contains(x, y)
and getattr(curve, "tooltip", None)
):
(name, value, total, dist) = curve.tooltip
count = sum([v[1] for v in dist])
if count == 0:
continue
tooltip_text = (
"Attribute: <b>%s</b><br>Value: <b>%s</b><br>"
"Total instances: <b>%i</b> (%.1f%%)<br>"
"Class distribution:<br>" % (name, value, count, 100.0 * count / float(total))
)
for (val, n) in dist:
tooltip_text += " <b>%s</b> : <b>%i</b> (%.1f%%)<br>" % (
val,
n,
100.0 * float(n) / float(count),
)
QToolTip.showText(ev.globalPos(), tooltip_text[:-4])
elif ev.type() == QEvent.MouseMove:
QToolTip.hideText()
return OWPlot.event(self, ev)