def __setup_plot(self): gs = GridSpec(1, 2, width_ratios=[9.5, 0.5]) self.axes = self.figure.add_subplot(gs[0], axisbg=self.settings.background) self.axes.set_xlabel("Frequency (MHz)") self.axes.set_ylabel('Time') numFormatter = ScalarFormatter(useOffset=False) timeFormatter = DateFormatter("%H:%M:%S") self.axes.xaxis.set_major_formatter(numFormatter) self.axes.yaxis.set_major_formatter(timeFormatter) self.axes.xaxis.set_minor_locator(AutoMinorLocator(10)) self.axes.yaxis.set_minor_locator(AutoMinorLocator(10)) self.axes.set_xlim(self.settings.start, self.settings.stop) now = time.time() self.axes.set_ylim(utc_to_mpl(now), utc_to_mpl(now - 10)) self.bar = self.figure.add_subplot(gs[1]) norm = Normalize(vmin=-50, vmax=0) self.barBase = ColorbarBase(self.bar, norm=norm, cmap=cm.get_cmap(self.settings.colourMap)) self.__setup_measure() self.__setup_overflow() self.hide_measure()
def __setup_plot(self): gs = GridSpec(1, 2, width_ratios=[9.5, 0.5]) self.axes = self.figure.add_subplot(gs[0], projection='3d') numformatter = ScalarFormatter(useOffset=False) timeFormatter = DateFormatter("%H:%M:%S") self.axes.set_xlabel("Frequency (MHz)") self.axes.set_ylabel('Time') self.axes.set_zlabel('Level ($\mathsf{dB/\sqrt{Hz}}$)') colour = hex2color(self.settings.background) colour += (1,) self.axes.w_xaxis.set_pane_color(colour) self.axes.w_yaxis.set_pane_color(colour) self.axes.w_zaxis.set_pane_color(colour) self.axes.xaxis.set_major_formatter(numformatter) self.axes.yaxis.set_major_formatter(timeFormatter) self.axes.zaxis.set_major_formatter(numformatter) self.axes.xaxis.set_minor_locator(AutoMinorLocator(10)) self.axes.yaxis.set_minor_locator(AutoMinorLocator(10)) self.axes.zaxis.set_minor_locator(AutoMinorLocator(10)) self.axes.set_xlim(self.settings.start, self.settings.stop) now = time.time() self.axes.set_ylim(utc_to_mpl(now), utc_to_mpl(now - 10)) self.axes.set_zlim(-50, 0) self.bar = self.figure.add_subplot(gs[1]) norm = Normalize(vmin=-50, vmax=0) self.barBase = ColorbarBase(self.bar, norm=norm, cmap=cm.get_cmap(self.settings.colourMap))
def __setup_plot(self): self.axes = self.figure.add_subplot(111) self.axes.set_xlabel("Time") self.axes.set_ylabel('Points') numFormatter = ScalarFormatter(useOffset=False) set_date_ticks(self.axes.xaxis, False) self.axes.yaxis.set_major_formatter(numFormatter) self.axes.yaxis.set_minor_locator(AutoMinorLocator(10)) now = time.time() self.axes.set_xlim(utc_to_mpl(now), utc_to_mpl(now - 10))
def __plot_peak(self, peakF, peakL, peakT): when = format_time(peakT) tPos = utc_to_mpl(peakT) text = '{}\n{}\n{when}'.format(*format_precision(self.settings, peakF, peakL, fancyUnits=True), when=when) if matplotlib.__version__ < '1.3': self.axes.text(peakF, tPos, peakL, text, ha='left', va='bottom', size='x-small', gid='peakText') self.axes.plot([peakF], [tPos], [peakL], marker='x', markersize=10, mew=3, color='w', gid='peak') self.axes.plot([peakF], [tPos], [peakL], marker='x', markersize=10, color='r', gid='peakShadow') else: effect = patheffects.withStroke(linewidth=2, foreground="w", alpha=0.75) self.axes.text(peakF, tPos, peakL, text, ha='left', va='bottom', size='x-small', gid='peakText', path_effects=[effect]) self.axes.plot([peakF], [tPos], [peakL], marker='x', markersize=10, color='r', gid='peak', path_effects=[effect])
def __plot_peak(self, peakF, peakL, peakT): self.__clear_markers() y = utc_to_mpl(peakT) start, stop = self.axes.get_xlim() textX = ((stop - start) / 50.0) + peakF when = format_time(peakT) text = '{}\n{}\n{when}'.format(*format_precision(self.settings, peakF, peakL, fancyUnits=True), when=when) if matplotlib.__version__ < '1.3': self.axes.annotate(text, xy=(peakF, y), xytext=(textX, y), ha='left', va='bottom', size='x-small', color='w', gid='peakText') self.axes.plot(peakF, y, marker='x', markersize=10, color='w', mew=3, gid='peakShadow') self.axes.plot(peakF, y, marker='x', markersize=10, color='r', gid='peak') else: effect = patheffects.withStroke(linewidth=2, foreground="w", alpha=0.75) self.axes.annotate(text, xy=(peakF, y), xytext=(textX, y), ha='left', va='bottom', size='x-small', path_effects=[effect], gid='peakText') self.axes.plot(peakF, y, marker='x', markersize=10, color='r', path_effects=[effect], gid='peak')
def create_mesh(spectrum, mplTime): total = len(spectrum) width = len(spectrum[min(spectrum)]) x = numpy.empty((width, total + 1)) * numpy.nan y = numpy.empty((width, total + 1)) * numpy.nan z = numpy.empty((width, total + 1)) * numpy.nan j = 1 for ys in spectrum: time = utc_to_mpl(ys) if mplTime else ys xs, zs = split_spectrum(spectrum[ys]) for i in range(len(xs)): x[i, j] = xs[i] y[i, j] = time z[i, j] = zs[i] j += 1 x[:, 0] = x[:, 1] if mplTime: y[:, 0] = y[:, 1] - seconds(1) else: y[:, 0] = y[:, 1] - 1 z[:, 0] = z[:, 1] return x, y, z
def __annotate_plot(self): f, l, t = self.extent.get_peak_flt() when = format_time(t) tPos = utc_to_mpl(t) text = '{}\n{}\n{when}'.format(*format_precision(self.settings, f, l, fancyUnits=True), when=when) if matplotlib.__version__ < '1.3': self.axes.text(f, tPos, l, text, ha='left', va='bottom', size='x-small', gid='peak') self.axes.plot([f], [tPos], [l], marker='x', markersize=10, mew=3, color='w', gid='peak') self.axes.plot([f], [tPos], [l], marker='x', markersize=10, color='r', gid='peak') else: effect = patheffects.withStroke(linewidth=2, foreground="w", alpha=0.75) self.axes.text(f, tPos, l, text, ha='left', va='bottom', size='x-small', gid='peak', path_effects=[effect]) self.axes.plot([f], [tPos], [l], marker='x', markersize=10, color='r', gid='peak', path_effects=[effect])
def __plot_peaks(self): sweep, indices = get_peaks(self.data, self.settings.peaksThres) lastTime = utc_to_mpl(max(self.data)) for i in indices: self.axes.plot(sweep.keys()[i], lastTime, linestyle='None', marker='+', markersize=10, color='r', gid='peakThres')
def scale_plot(self, force=False): if self.figure is not None and self.plot is not None: if self.settings.autoT or force: times = self.plot[0].get_data()[0] tMin = min(times) tMax = max(times) if tMin == tMax: tMax += utc_to_mpl(10) self.axes.set_xlim(tMin, tMax) if self.settings.autoL or force: self.axes.autoscale(True, 'y', True)
def run(self): if self.data is None: self.parent.threadPlot = None return total = len(self.data) if total > 0: self.parent.clear_plots() xs = [utc_to_mpl(x) for x in self.data.keys()] ys = [len(sweep) for sweep in self.data.values()] self.parent.plot = self.axes.plot(xs, ys, 'bo', gid='plot') set_date_ticks(self.axes.xaxis) self.parent.scale_plot() self.parent.redraw_plot() self.parent.threadPlot = None
def get_t(self): return utc_to_mpl(self.tMax), utc_to_mpl(self.tMin - 1)