def create_plot(self): if self.plot is not None: self.plot.close() self.toolbar.set_auto(True) if self.settings.display == Display.PLOT: self.plot = Plotter(self.notify, self.figure, self.settings) elif self.settings.display == Display.SPECT: self.plot = Spectrogram(self.notify, self.figure, self.settings) elif self.settings.display == Display.SURFACE: self.plot = Plotter3d(self.notify, self.figure, self.settings) elif self.settings.display == Display.STATUS: self.plot = PlotterStatus(self.notify, self.figure, self.settings) elif self.settings.display == Display.TIMELINE: self.plot = PlotterTime(self.notify, self.figure, self.settings) self.__set_fonts() self.toolbar.set_plot(self.plot) self.toolbar.set_type(self.settings.display) self.measureTable.set_type(self.settings.display) self.set_plot_title() self.figure.subplots_adjust(top=0.85) self.redraw_plot() self.plot.scale_plot(True) self.mouseZoom = MouseZoom(self.toolbar, plot=self.plot, callbackHide=self.__hide_overlay) self.mouseSelect = MouseSelect(self.plot, self.on_select, self.on_selected) self.measureTable.show(self.settings.showMeasure) self.panel.SetFocus()
def __init__(self, parent, callback): self.callback = callback self.spectrum1 = None self.spectrum2 = None self.spectrumDiff = None self.mouseZoom = None formatter = ScalarFormatter(useOffset=False) wx.Panel.__init__(self, parent) figure = matplotlib.figure.Figure(facecolor='white') figure.set_size_inches(8, 4.5) if matplotlib.__version__ >= '1.2': figure.set_tight_layout(True) self.axesScan = figure.add_subplot(111) self.axesScan.xaxis.set_minor_locator(AutoMinorLocator(10)) self.axesScan.yaxis.set_minor_locator(AutoMinorLocator(10)) self.axesScan.xaxis.set_major_formatter(formatter) self.axesScan.yaxis.set_major_formatter(formatter) self.axesDiff = self.axesScan.twinx() self.axesDiff.yaxis.set_minor_locator(AutoMinorLocator(10)) self.plotScan1, = self.axesScan.plot([], [], 'b-', linewidth=0.4) self.plotScan2, = self.axesScan.plot([], [], 'g-', linewidth=0.4) self.plotDiff, = self.axesDiff.plot([], [], 'r-', linewidth=0.4) self.axesScan.set_ylim(auto=True) self.axesDiff.set_ylim(auto=True) self.axesScan.set_title("Level Comparison") self.axesScan.set_xlabel("Frequency (MHz)") self.axesScan.set_ylabel('Level (dB/Hz)') self.axesDiff.set_ylabel('Difference (dB/Hz)') self.canvas = FigureCanvas(self, -1, figure) self.set_grid(True) self.textIntersect = wx.StaticText(self, label="Intersections: ") toolbar = NavigationToolbarCompare(self) toolbar.Realize() self.mouseZoom = MouseZoom(toolbar, figure=figure) vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) vbox.Add(self.textIntersect, 0, wx.EXPAND | wx.ALL, border=5) vbox.Add(toolbar, 0, wx.EXPAND) self.SetSizer(vbox) vbox.Fit(self) self.canvas.mpl_connect('motion_notify_event', self.__on_motion) self.canvas.mpl_connect('axes_leave_event', self.__on_leave)