)
self.execute_command(
command=self._command_by_name('polymer fit'),
- args={'block':1, 'bounds':[400, 1000]},
+ args={'block':1, 'bounds':[918, 1103]},
)
return # TODO: cleanup
self.playlists = self._c['playlist'].Playlists
# style=wx.NO_BORDER|wx.TE_MULTILINE), 'right'),
(panel.PANELS['plot'](
callbacks={
+ '_set_status_text': self._on_plot_status_text,
},
parent=self,
style=wx.WANTS_CHARS|wx.NO_BORDER,
+ # Plot panel interface
+
+ def _on_plot_status_text(self, _class, method, text):
+ if 'status bar' in self._c:
+ self._c['status bar'].set_plot_text(text)
+
+
+
# Navbar interface
def _next_curve(self, *args):
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
dialog.CenterOnScreen()
dialog.ShowModal()
+ if dialog.canceled == True:
+ return
names = [options[i] for i in dialog.selected]
dialog.Destroy()
self._delete_perspectives(
from matplotlib.backends.backend_wx import NavigationToolbar2Wx as NavToolbar
from matplotlib.figure import Figure
from matplotlib.ticker import Formatter, ScalarFormatter
+import numpy
import wx
from ....util.callback import callback, in_callback
self.display_coordinates = False
self.style = 'line'
self._curve = None
+ self._config = {}
self._x_column = None
self._y_columns = [] # TODO: select right/left scales?
+ self._x_unit = ''
+ self._y_unit = ''
super(PlotPanel, self).__init__(
name='plot', callbacks=callbacks, **kwargs)
self._c = {}
self._c['figure'].set_edgecolor(col)
self._c['canvas'].SetBackgroundColour(wx.Colour(*rgbtuple))
- #def SetStatusText(self, text, field=1):
- # self.Parent.Parent.statusbar.SetStatusText(text, field)
+ def _set_status_text(self, text):
+ in_callback(self, text)
def _on_size(self, event):
event.Skip()
wx.CallAfter(self._resize_canvas)
def _on_click(self, event):
- #self.SetStatusText(str(event.xdata))
- #print 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f'%(event.button, event.x, event.y, event.xdata, event.ydata)
- pass
+ if self._curve == None:
+ return
+ d = self._config.get('plot decimals', 2)
+ x,y = (event.xdata, event.ydata)
+ xt = ppSI(value=x, unit=self._x_unit, decimals=d)
+ yt = ppSI(value=y, unit=self._y_unit, decimals=d)
+ point_indexes = []
+ for data in self._curve.data:
+ try:
+ x_col = data.info['columns'].index(self._x_column)
+ except ValueError:
+ continue # data is missing a required column
+ index = numpy.absolute(data[:,x_col]-x).argmin()
+ point_indexes.append((data.info['name'], index))
+ self._set_status_text(
+ '(%s, %s) %s'
+ % (xt, yt,
+ ', '.join(['%s: %d' % (n,i) for n,i in point_indexes])))
def _on_enter_axes(self, event):
self.display_coordinates = True
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
s.CenterOnScreen()
s.ShowModal()
+ if s.canceled == True:
+ return
self._y_columns = [self._columns[i] for i in s.selected]
s.Destroy()
if len(self._y_columns) == 0:
if config['plot SI format'] == True:
d = config['plot decimals']
- x_n, x_unit = split_data_label(self._x_column)
- y_n, y_unit = split_data_label(self._y_columns[0])
+ x_n, self._x_unit = split_data_label(self._x_column)
+ y_n, self._y_unit = split_data_label(self._y_columns[0])
for y_column in self._y_columns[1:]:
- y_n2, y_unit2 = split_data_label(y_column)
- if y_unit2 != y_unit:
+ y_n, y_unit = split_data_label(y_column)
+ if y_unit != self._y_unit:
log = logging.getLogger('hooke')
log.warn('y-axes unit mismatch: %s != %s, using %s.'
- % (y_unit, y_unit2, y_unit))
- fx = HookeFormatter(decimals=d, unit=x_unit)
+ % (self._y_unit, y_unit, self._y_unit))
+ fx = HookeFormatter(decimals=d, unit=self._x_unit)
axes.xaxis.set_major_formatter(fx)
- fy = HookeFormatter(decimals=d, unit=y_unit)
+ fy = HookeFormatter(decimals=d, unit=self._y_unit)
axes.yaxis.set_major_formatter(fy)
axes.set_xlabel(x_n)
if len(self._y_columns) == 1:
axes.set_ylabel(y_n)
else:
+ self._x_unit = ''
+ self._y_unit = ''
axes.set_xlabel(self._x_column)
if len(self._y_columns) == 1:
axes.set_ylabel(self._y_columns[0])