Changeset 3552:492fa6667bff in orange
 Timestamp:
 04/18/07 10:17:12 (7 years ago)
 Branch:
 default
 Convert:
 8e5c616b5463903609edcccb32a6c00dac8866df
 Location:
 orange/OrangeWidgets/Visualize
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

orange/OrangeWidgets/Visualize/OWCorrAnalysis.py
r3403 r3552 18 18 textCorpusModul = 1 19 19 20 try: 21 from orngTextCorpus import CategoryDocument, checkFromText 22 except ImportError: 23 textCorpusModul = 0 20 #try: 21 # from orngTextCorpus import CategoryDocument, checkFromText 22 #except ImportError: 23 # textCorpusModul = 0 24 24 25 25 26 import os 27 28 def checkFromText(data): 29 if not isinstance(data, orange.ExampleTable): 30 return False 31 if len(data.domain.attributes) < 10 and len(data.domain.getmetas()) > 15: 32 return True 33 elif len(data.domain.attributes) * 2 < len(data.domain.getmetas()): 34 return True 35 return False 26 36 27 37 class OWCorrAnalysis(OWWidget): … … 123 133 OWGUI.checkBox(box4, self, 'showGridlines', 'Show gridlines', callback = self.setShowGridlines) 124 134 ## OWGUI.checkBox(box4, self, 'graph.showClusters', 'Show clusters', callback = self.updateGraph, tooltip = "Show a line boundary around a significant cluster") 135 OWGUI.checkBox(box4, self, 'graph.showRowLabels', 'Show row labels', callback = self.updateGraph) 136 OWGUI.checkBox(box4, self, 'graph.showColumnLabels', 'Show column labels', callback = self.updateGraph) 137 125 138 126 139 self.colorButtonsBox = OWGUI.widgetBox(self.SettingsTab, " Colors ", orientation = "horizontal") … … 129 142 #browsing radius 130 143 OWGUI.hSlider(self.SettingsTab, self, 'percRadius', box=' Browsing Curve Size ', minValue = 0, maxValue=100, step=5, callback = self.calcRadius) 144 145 #font size 146 OWGUI.hSlider(self.SettingsTab, self, 'graph.labelSize', box=' Set font size for labels ', minValue = 8, maxValue=48, step=1, callback = self.updateGraph) 147 148 OWGUI.hSlider(self.SettingsTab, self, 'graph.maxPoints', box=' Maximum number of points ', minValue = 10, maxValue=40, step=1, callback = None) 149 131 150 132 151 … … 168 187 if self.data == None: return 169 188 170 if self.textData: 189 if self.textData: 171 190 self.attrRowCombo.insertItem('document') 172 191 self.attrRowCombo.insertItem('category') 173 192 self.attrColCombo.insertItem('words') 174 else: 193 else: 175 194 for attr in self.data.domain: 176 195 if attr.varType == orange.VarTypes.Discrete: self.attrRowCombo.insertItem(self.icons[attr.varType], attr.name) … … 180 199 if self.attrColCombo.count() > 1: 181 200 self.attrCol = str(self.attrColCombo.text(1)) 182 else: 201 else: 183 202 self.attrCol = str(self.attrColCombo.text(0)) 184 203 … … 204 223 self.CA = orngCA.CA(caList) 205 224 try: 206 self.tipsR = [ex[' meta'].native() for ex in data]225 self.tipsR = [ex['name'].native() for ex in data] 207 226 except: 208 227 self.tipsR = [ex.name for ex in data] … … 282 301 cor = [cor[i] for i in indices] 283 302 tipsR = [self.tipsR[i] for i in indices] 303 if not self.graph.showRowLabels: tipsR = ['' for i in indices] 284 304 self.plotPoint(cor, 0, tipsR, "Row points", self.graph.showFilledSymbols) 285 305 … … 289 309 cor = [cor[i] for i in indices] 290 310 tipsC = [self.tipsC[i] for i in indices] 311 if not self.graph.showColumnLabels: tipsC = ['' for i in indices] 291 312 self.plotPoint(cor, 1, tipsC, "Column points", self.graph.showFilledSymbols) 292 313 
orange/OrangeWidgets/Visualize/OWCorrAnalysisGraph.py
r3402 r3552 28 28 ## self.showClusters = 0 29 29 self.showFilledSymbols = 1 30 self.labelSize = 12 31 self.showRowLabels = 1 32 self.showColumnLabels = 1 33 self.maxPoints = 10 30 34 31 35 ## self.tooltipKind = 1 … … 97 101 self.markLines = [] 98 102 ## print self.tips.positions 103 99 104 cor = [(x, y, self.tips.texts[i]) for (i,(x,y, cx, cy)) in enumerate(self.tips.positions) if abs(xFloat  x) <= self.radius and abs(yFloat  y) <= self.radius] 100 105 self.addMarkers(cor, xFloat, yFloat, self.radius) … … 117 122 self.removeCurve(line) 118 123 self.markLines = [] 119 cor = [(x, y, self.tips.texts[i]) for (i,(x,y )) in enumerate(self.tips.positions) if ((xFloat  x)*(xFloat  x) + (yFloat  y)*(yFloat  y) <= self.radius * self.radius)]124 cor = [(x, y, self.tips.texts[i]) for (i,(x,y, cx, cy)) in enumerate(self.tips.positions) if ((xFloat  x)*(xFloat  x) + (yFloat  y)*(yFloat  y) <= self.radius * self.radius)] 120 125 self.addMarkers(cor, xFloat, yFloat, self.radius) 121 126 ## for x, y, text in cor: … … 192 197 right = x + r 193 198 ## right = self.transform(QwtPlot.xBottom, right) + 20 194 ## right = self.invTransform(QwtPlot.xBottom, right) 199 ## right = self.invTransform(QwtPlot.xBottom, right) 200 posX = x 201 posY = y 202 topR = topL = top 195 203 196 204 newMark = [] 197 for i, (x, y, text) in zip(range(len(cor)), cor): 205 points = zip(range(len(cor)), cor) 206 #sort using height 207 points.sort(cmp = lambda x,y: cmp(x[1][1], y[1][1])) 208 prevY = points[0][1][1] 209 i = 1 210 211 # while i <= len(points)  1: 212 # y = points[i][1][1] 213 # if prevY  y < 10 and points[i1][1][0] < points[i][1][0]: 214 # t = points[i] 215 # points[i] = points[i1] 216 # points[i1] = t 217 # i = i + 1 218 219 220 for i, (x, y, text) in points: 198 221 side = left 199 if not (i & 1): 200 if self.checkPerc(left) > 0: 201 newMark.append((left, self.invTransform(QwtPlot.yLeft, top), text, Qt.AlignLeft, x, y)) 222 if not text: continue 223 224 if x < posX: 225 #pokusaj lijevo 226 if self.checkPerc(left, len(text)) > 0: 227 newMark.append((left, self.invTransform(QwtPlot.yLeft, topL), text, Qt.AlignLeft, x, y)) 228 topL = topL + self.labelSize 202 229 else: 203 newMark.append((right, self.invTransform(QwtPlot.yLeft, top ), text, Qt.AlignRight, x, y))204 top = top + 10230 newMark.append((right, self.invTransform(QwtPlot.yLeft, topR), text, Qt.AlignRight, x, y)) 231 topR = topR + self.labelSize 205 232 else: 206 if self.checkPerc(right) < 70: 207 newMark.append((right, self.invTransform(QwtPlot.yLeft, top), text, Qt.AlignRight, x, y)) 233 #pokusaj desno 234 if self.checkPerc(right, len(text)) < 70: 235 newMark.append((right, self.invTransform(QwtPlot.yLeft, topR), text, Qt.AlignRight, x, y)) 236 topR = topR + self.labelSize 208 237 else: 209 top = top + 10 210 newMark.append((left, self.invTransform(QwtPlot.yLeft, top), text, Qt.AlignLeft, x, y)) 211 top = top + 10 238 topL = topL + self.labelSize 239 newMark.append((left, self.invTransform(QwtPlot.yLeft, topL), text, Qt.AlignLeft, x, y)) 240 241 # if not (i & 1): 242 # if self.checkPerc(left) > 0: 243 # newMark.append((left, self.invTransform(QwtPlot.yLeft, top), text, Qt.AlignLeft, x, y)) 244 # else: 245 # newMark.append((right, self.invTransform(QwtPlot.yLeft, top), text, Qt.AlignRight, x, y)) 246 # top = top + 10 247 # else: 248 # if self.checkPerc(right) < 70: 249 # newMark.append((right, self.invTransform(QwtPlot.yLeft, top), text, Qt.AlignRight, x, y)) 250 # else: 251 # top = top + 10 252 # newMark.append((left, self.invTransform(QwtPlot.yLeft, top), text, Qt.AlignLeft, x, y)) 253 # top = top + 10 254 prevYR = prevYL = 666 255 prevIndL = prevIndR = 1 256 prevXL = prevXR = 0 257 i = 0 258 259 while i <= len(newMark)  1: 260 y = newMark[i][1] 261 if newMark[i][3] == Qt.AlignLeft: 262 if abs(prevYL  y) < abs(prevXL  newMark[i][0]): 263 t = newMark[i] 264 newMark[i] = newMark[prevIndL] 265 newMark[prevIndL] = t 266 prevYL = y 267 prevXL = newMark[i][0] 268 prevIndL = i 269 if newMark[i][3] == Qt.AlignRight: 270 if abs(prevYR  y) < abs(prevXR  newMark[i][0]): 271 t = newMark[i] 272 newMark[i] = newMark[prevIndR] 273 newMark[prevIndR] = t 274 prevYR = y 275 prevXR = newMark[i][0] 276 prevIndR = i 277 i = i + 1 278 279 212 280 213 281 for x, y, text, al, x1, y1 in newMark: 214 self.addMarker(text, x, y, alignment = al, color = QColor( ))282 self.addMarker(text, x, y, alignment = al, color = QColor(255,0,0), size = self.labelSize) 215 283 self.markLines.append(self.addCurve("", QColor("black"), QColor("black"), 1, QwtCurve.Lines, xData = [x, x1], yData = [y, y1] )) 216 284 217 285 218 def checkPerc(self, x ):286 def checkPerc(self, x, textLen): 219 287 div = self.axisScale(QwtPlot.xBottom) 220 288 if x < div.lBound():
Note: See TracChangeset
for help on using the changeset viewer.