Changeset 47:8c29813f5150 in orange
- Timestamp:
- 04/02/03 09:30:38 (10 years ago)
- Branch:
- default
- Convert:
- 71d91b367ef04c48fe012c9fa763f36954af6cea
- File:
-
- 1 edited
-
orange/OrangeWidgets/OWDistributions.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
orange/OrangeWidgets/OWDistributions.py
r32 r47 20 20 from OWGraph import * 21 21 22 class subBarQwt Curve(QwtCurve):22 class subBarQwtPlotCurve(QwtPlotCurve): 23 23 def __init__(self, parent = None, text = None): 24 Qwt Curve.__init__(self, parent, text)24 QwtPlotCurve.__init__(self, parent, text) 25 25 self.color = Qt.black 26 26 … … 38 38 px2 = xMap.transform(self.x(i+1)) 39 39 py2 = yMap.transform(self.y(i+1)) 40 # print "draw from ", px1, ",", py1, "to", px2, ",", py241 40 p.drawRect(px1, py1, (px2 - px1), (py2 - py1)) 42 41 43 class subBarQwtPlotCurve(QwtPlotCurve, subBarQwtCurve): # there must be a better way to do this 44 def dummy(): 45 None 42 class errorBarQwtPlotCurve(QwtPlotCurve): 43 def __init__(self, parent = None, text = None): 44 QwtPlotCurve.__init__(self, parent, text) 45 46 def draw(self, p, xMap, yMap, f, t): 47 self.setPen( self.symbol().pen() ) 48 p.setPen( self.symbol().pen() ) 49 if self.style() == QwtCurve.UserCurve: 50 p.setBackgroundMode(Qt.OpaqueMode) 51 if t < 0: t = self.dataSize() - 1 52 if divmod(f, 3)[1] != 0: f -= f % 3 53 if divmod(t, 3)[1] == 0: t += 1 54 for i in range(f, t+1, 3): 55 px = xMap.transform(self.x(i)) 56 pxl = xMap.transform(self.x(i) - 0.1) 57 pxr = xMap.transform(self.x(i) + 0.1) 58 py1 = yMap.transform(self.y(i + 0)) 59 py2 = yMap.transform(self.y(i + 1)) 60 py3 = yMap.transform(self.y(i + 2)) 61 p.drawLine(px, py1, px, py3) 62 p.drawLine(pxl, py1, pxr, py1) 63 p.drawLine(pxl, py3, pxr, py3) 64 self.symbol().draw(p, px, py2) 65 else: 66 QwtPlotCurve.draw(self, p, xMap, yMap, f, t) 67 46 68 47 69 class OWDistributions(OWWidget): … … 91 113 self.outcomenames = [] 92 114 self.probGraphValues = [] 93 self.probCurveKey = self.graph.insertCurve('', QwtPlot.xBottom, QwtPlot.yRight) 115 116 curve = errorBarQwtPlotCurve(self.graph, '') 117 self.probCurveKey = self.graph.insertCurve(curve) 118 self.graph.setCurveXAxis(self.probCurveKey, QwtPlot.xBottom) 119 self.graph.setCurveYAxis(self.probCurveKey, QwtPlot.yRight) 120 94 121 self.probCurveUpperCIKey = self.graph.insertCurve('', QwtPlot.xBottom, QwtPlot.yRight) 95 122 self.probCurveLowerCIKey = self.graph.insertCurve('', QwtPlot.xBottom, QwtPlot.yRight) … … 308 335 309 336 self.graph.removeCurves() 310 ## newColor = QColor()311 ## newColor.setHsv(5*360/12, 255, 255)312 ## curve = subBarQwtPlotCurve(self.graph)313 ## curve.setPen(QPen(newColor))314 ## ckey = self.graph.insertCurve(curve)315 ## self.graph.setCurveStyle(ckey, QwtCurve.UserCurve)316 ## self.graph.setCurveData(ckey, [10, 11], [5, 7])317 337 318 338 currentBarsHeight = [0] * len(keys) … … 337 357 currentBarsHeight[cn] += subBarHeight 338 358 cn += 1 339 self.probCurveKey = self.graph.insertCurve('', QwtPlot.xBottom, QwtPlot.yRight) 359 360 curve = errorBarQwtPlotCurve(self.graph, '') 361 self.probCurveKey = self.graph.insertCurve(curve) 362 self.graph.setCurveXAxis(self.probCurveKey, QwtPlot.xBottom) 363 self.graph.setCurveYAxis(self.probCurveKey, QwtPlot.yRight) 364 340 365 self.probCurveUpperCIKey = self.graph.insertCurve('', QwtPlot.xBottom, QwtPlot.yRight) 341 366 self.probCurveLowerCIKey = self.graph.insertCurve('', QwtPlot.xBottom, QwtPlot.yRight) … … 344 369 def refreshProbGraph(self): 345 370 if self.ShowProbabilities: 346 if self.VariableContinuous:347 newSymbol = QwtSymbol()348 else:349 newSymbol = QwtSymbol() #QwtSymbol.Cross, QBrush(Qt.red), QPen(Qt.red), QSize(1,100))350 351 371 self.graph.enableYRaxis(1) 352 372 xs = [] … … 358 378 if self.VariableContinuous: 359 379 xs.append(x) 380 ups.append(ps[self.targetValue] + cis[self.targetValue]) 381 mps.append(ps[self.targetValue] + 0.0) 382 lps.append(ps[self.targetValue] - cis[self.targetValue]) 360 383 else: 384 if self.ShowConfidenceIntervals: 385 xs.append(cn) 386 mps.append(ps[self.targetValue] + cis[self.targetValue]) 387 361 388 xs.append(cn) 362 ups.append(ps[self.targetValue] + cis[self.targetValue]) 363 mps.append(ps[self.targetValue] + 0.0) 364 lps.append(ps[self.targetValue] - cis[self.targetValue]) 389 mps.append(ps[self.targetValue] + 0.0) 390 391 if self.ShowConfidenceIntervals: 392 xs.append(cn) 393 mps.append(ps[self.targetValue] - cis[self.targetValue]) 365 394 cn += 1.0 395 396 ## (re)set the curves 397 if self.VariableContinuous: 398 newSymbol = QwtSymbol(QwtSymbol.None, QBrush(Qt.color0), QPen(Qt.black, 2), QSize(0,0)) 399 else: 400 newSymbol = QwtSymbol(QwtSymbol.Diamond, QBrush(Qt.color0), QPen(Qt.black, 2), QSize(7,7)) 366 401 367 402 self.graph.setCurveData(self.probCurveKey, xs, mps) 368 403 self.graph.setCurveSymbol(self.probCurveKey, newSymbol) 369 if self.ShowConfidenceIntervals: 370 self.graph.setCurveData(self.probCurveUpperCIKey, xs, ups) 371 self.graph.setCurveData(self.probCurveLowerCIKey, xs, lps) 404 405 if self.VariableContinuous: 406 self.graph.setCurveStyle(self.probCurveKey, QwtCurve.Lines) 407 if self.ShowConfidenceIntervals: 408 self.graph.setCurveData(self.probCurveUpperCIKey, xs, ups) 409 self.graph.setCurveData(self.probCurveLowerCIKey, xs, lps) 410 else: 411 if self.ShowConfidenceIntervals: 412 self.graph.setCurveStyle(self.probCurveKey, QwtCurve.UserCurve) 413 else: 414 self.graph.setCurveStyle(self.probCurveKey, QwtCurve.Dots) 372 415 else: 373 416 self.graph.enableYRaxis(0)
Note: See TracChangeset
for help on using the changeset viewer.
