from PyQt4 import QtGui from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas #from matplotlib.figure import Figure import matplotlib.pyplot as plt from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar class MplCanvas(FigureCanvas): def __init__(self, parent = None): fig = plt.figure()#(facecolor='black') self.ax1 = fig.add_subplot(211)#, axisbg='k') self.ax2 = fig.add_subplot(212)#, axisbg='k') #plt.ion() #self.ax1.hold(False) #self.ax1.spines['top'].set_color('white') #self.ax1.spines['right'].set_color('white') #self.ax1.spines['bottom'].set_color('white') #self.ax1.spines['left'].set_color('white') #self.ax1.title.set_color('white') #self.ax1.yaxis.label.set_color('white') #self.ax1.xaxis.label.set_color('white') #self.ax1.tick_params(axis='x', colors='white') #self.ax1.tick_params(axis='y', colors='white') #self.ax2.spines['top'].set_color('white') #self.ax2.spines['right'].set_color('white') #self.ax2.spines['bottom'].set_color('white') #self.ax2.spines['left'].set_color('white') #self.ax2.title.set_color('white') #self.ax2.yaxis.label.set_color('white') #self.ax2.xaxis.label.set_color('white') #self.ax2.tick_params(axis='x', colors='white') #self.ax2.tick_params(axis='y', colors='white') #self.ax1.set_xlabel('Time (s)') #self.ax1.set_ylabel('Signal (V)') #self.ax2.set_xlabel('Position (mm)') #self.ax2.set_ylabel('Amplitude (arb. units)') self.ax1.grid(True)#, c='w') self.ax2.grid(True)#, c='w') FigureCanvas.__init__(self, fig) self.setParent(parent) FigureCanvas.setSizePolicy(self,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) def plot_graph(self, x, y): # x =len(ch1_data))/float(self.rate) self.ax1.clear() self.ax1.plot(x, y, c='m', lw=1.5) #self.ax1.axhline(y=self.trig_lvl, c='y') #self.ax1.ticklabel_format(style='sci', axis='x', scilimits=(0,0)) self.ax1.set_xlabel('Time (s)') self.ax1.set_ylabel('Signal (V)') self.ax1.grid(True, c='w') self.draw() #plt.pause(0.001) return class MplWidget(QtGui.QWidget): def __init__(self, parent = None): QtGui.QWidget.__init__(self, parent) self.canvas = MplCanvas() #self.mpl_toolbar = NavigationToolbar(self.canvas,self) self.vbl = QtGui.QVBoxLayout() self.vbl.addWidget(self.canvas) #self.vbl.addWidget(self.mpl_toolbar) self.setLayout(self.vbl)