Changeset 057210c in sasview
- Timestamp:
- Mar 17, 2008 10:10:20 AM (17 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 4e290cd
- Parents:
- 2bf92f2
- Location:
- guitools
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
guitools/PlotPanel.py
r2bf92f2 r057210c 10 10 from canvas import FigureCanvas 11 11 #TODO: make the plottables interactive 12 from plottables import Graph 12 13 13 14 def show_tree(obj,d=0): … … 46 47 self.SetSizer(sizer) 47 48 48 49 # Graph object to manage the plottables 50 self.graph = Graph() 49 51 50 52 self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu) -
guitools/plottables.py
r2bf92f2 r057210c 123 123 """Properties of the y axis. 124 124 """ 125 if self.prop[" xunit"] and units != self.prop["xunit"]:125 if self.prop["yunit"] and units != self.prop["yunit"]: 126 126 pass 127 127 #print "Plottable: how do we handle non-commensurate units" 128 128 self.prop["ylabel"] = "%s (%s)"%(name,units) 129 self.prop[" xunit"] = units129 self.prop["yunit"] = units 130 130 131 131 def title(self,name): … … 348 348 """Return the number of colors need to render the object""" 349 349 return 1 350 350 351 class View: 352 """ 353 Representation of the data that might include a transformation 354 """ 355 x = None 356 y = None 357 dx = None 358 dy = None 359 360 def __init__(self, x=None, y=None, dx=None, dy=None): 361 self.x = x 362 self.y = y 363 self.dx = dx 364 self.dy = dy 365 366 def transform_x(self, func, errfunc, x, dx): 367 """ 368 Transforms the x and dx vectors and stores the output. 369 370 @param func: function to apply to the data 371 @param x: array of x values 372 @param dx: array of error values 373 @param errfunc: function to apply to errors 374 """ 375 import copy 376 # Sanity check 377 if dx and not len(x)==len(dx): 378 raise ValueError, "Plottable.View: Given x and dx are not of the same length" 379 380 self.x = deepcopy(x) 381 self.dx = deepcopy(dx) 382 383 for i in range(len(x)): 384 self.x[i] = func(x[i]) 385 self.dx[i] = errfunc(dx[i]) 386 387 def transform_y(self, func, errfunc, y, dy): 388 """ 389 Transforms the x and dx vectors and stores the output. 390 391 @param func: function to apply to the data 392 @param y: array of y values 393 @param dy: array of error values 394 @param errfunc: function to apply to errors 395 """ 396 import copy 397 # Sanity check 398 if dy and not len(y)==len(dy): 399 raise ValueError, "Plottable.View: Given y and dy are not of the same length" 400 401 self.y = deepcopy(y) 402 self.dy = deepcopy(dy) 403 404 for i in range(len(y)): 405 self.y[i] = func(y[i]) 406 self.dy[i] = errfunc(dy[i]) 407 408 351 409 352 410 class Data1D(Plottable): … … 362 420 The label, if it is different, appears on the status bar. 363 421 """ 422 self.name = "data" 364 423 self.x = x 365 424 self.y = y 366 425 self.dx = dx 367 426 self.dy = dy 427 428 self.view = self.View(self.x, self.y, self.dx, self.dy) 368 429 369 430 def render(self,plot,**kw): 370 Plottable.render(self,plot) 371 plot.points(self.x,self.y,dx=self.dx,dy=self.dy,**kw) 431 plot.points(self.view.x,self.view.y,dx=self.view.dx,dy=self.view.dy,**kw) 372 432 373 433 def changed(self): 374 434 return False 375 435 436 @classmethod 437 def labels(cls, collection): 438 """Build a label mostly unique within a collection""" 439 map = {} 440 for item in collection: 441 #map[item] = label(item, collection) 442 map[item] = r"$\rm{%s}$" % item.name 443 return map 376 444 377 445 class Theory1D(Plottable):
Note: See TracChangeset
for help on using the changeset viewer.