def set_grid(self, on): table = find_artists(self.axes, 'table') if len(table): if on: colour = 'LightGray' else: colour = 'w' set_table_colour(table[0], colour) self.redraw_plot()
def set_grid(self, on): table = find_artists(self.axes, "table") if len(table): if on: colour = "LightGray" else: colour = "w" set_table_colour(table[0], colour) self.redraw_plot()
def __on_motion(self, event): xpos = event.xdata ypos = event.ydata text = "" if xpos is None or ypos is None or self.spectrum is None: return if self.settings.display == Display.PLOT: timeStamp = max(self.spectrum) spectrum = self.spectrum[timeStamp] elif self.settings.display == Display.SPECT: timeStamp = num2epoch(ypos) if timeStamp in self.spectrum: spectrum = self.spectrum[timeStamp] else: nearest = min(self.spectrum.keys(), key=lambda k: abs(k - timeStamp)) spectrum = self.spectrum[nearest] elif self.settings.display == Display.SURFACE: spectrum = None coords = self.plot.get_axes().format_coord(event.xdata, event.ydata) match = re.match('x=([-|0-9|\.]+).*y=([0-9|\:]+).*z=([-|0-9|\.]+)', coords) if match is not None and match.lastindex == 3: freq = float(match.group(1)) level = float(match.group(3)) text = "{}, {}".format(*format_precision(self.settings, freq, level)) else: spectrum = None if spectrum is not None and len(spectrum) > 0: x = min(spectrum.keys(), key=lambda freq: abs(freq - xpos)) if min(spectrum.keys(), key=float) <= xpos <= max(spectrum.keys(), key=float): y = spectrum[x] text = "{}, {}".format(*format_precision(self.settings, x, y)) else: text = format_precision(self.settings, xpos) self.status.set_info(text, level=None) axes = self.figure.get_axes()[0] markers = find_artists(self.figure, 'peak') markers.extend(find_artists(self.figure, 'peakThres')) hit = False for marker in markers: if isinstance(marker, Line2D): location = marker.get_path().vertices[0] markX, markY = axes.transData.transform(location) dist = abs(math.hypot(event.x - markX, event.y - markY)) if dist <= 5: if self.settings.display == Display.PLOT: tip = "{}, {}".format(*format_precision(self.settings, location[0], location[1])) else: tip = "{}".format(format_precision(self.settings, location[0])) self.toolTip.SetTip(tip) hit = True break self.toolTip.Enable(hit)
def clear_plots(self): table = find_artists(self.figure, 'table') if table: table[0].remove()
def clear_plots(self): table = find_artists(self.figure, 'table') if table: table[0].remove() noData = find_artists(self.figure, 'noData') noData[0].set_alpha(1)
def run(self): self.parent.clear_plots() if self.data is None: self.parent.threadPlot = None return tMin = format_time(self.extent.tMin, True) tMax = format_time(self.extent.tMax, True) fMin = format_precision(self.settings, freq=self.extent.fMin, fancyUnits=True) fMax = format_precision(self.settings, freq=self.extent.fMax, fancyUnits=True) lMin = format_precision(self.settings, level=self.extent.lMin, fancyUnits=True) lMax = format_precision(self.settings, level=self.extent.lMax, fancyUnits=True) peak = self.extent.get_peak_flt() peakF = format_precision(self.settings, freq=peak[0], fancyUnits=True) peakL = format_precision(self.settings, level=peak[1], fancyUnits=True) peakT = format_time(peak[2], True) text = [['Sweeps', '', len(self.data)], ['Extents', '', ''], ['', 'Start', tMin], ['', 'End', tMax], ['', 'Min frequency', fMin], ['', 'Max frequency', fMax], ['', 'Min level', lMin], ['', 'Max level', lMax], ['Peak', '', ''], ['', 'Level', peakL], ['', 'Frequency', peakF], ['', 'Time', peakT], ] table = Table(self.axes, loc='center', gid='table') rows = len(text) cols = len(text[0]) for row in xrange(rows): for col in xrange(cols): table.add_cell(row, col, text=text[row][col], width=1.0 / cols, height=1.0 / rows) if self.settings.grid: colour = 'LightGray' else: colour = 'w' set_table_colour(table, colour) for i in range(3): table.auto_set_column_width(i) self.axes.add_table(table) noData = find_artists(self.axes, 'noData') noData[0].set_alpha(0) self.parent.redraw_plot() self.parent.threadPlot = None