I'm running into an issue when trying to call up matplotlib figures from a PyQt GUI. The figures themselves display fine, but as soon as they appear I get an ugly blank grey screen behind both my GUI and figure. This does not go away until I have closed the GUI.
Here's the section of my GUI in which I call the function, in another script, that should display my graph. I would post the whole thing but it's quite long.
def readSignal(self):
signal = self.buttonGroup.checkedId() #reads integer signal from analysis options
timeStamps,deltaPix,fps=motionTools.loadData(self.filenames+"/")
if signal == 1:
motionTools.motionInROI(timeStamps,deltaPix)
elif signal == 2:
motionTools.barTimeInROI(deltaPix)
else:
self.analysisOptionError.show()
Both of these motionTools functions use the data (timeStamps and deltaPix are slices of arrays, fps is a frames-per-second integer) to generate different graphs. Here's an example of one of them (barTimeInROI) - both cause this grey screen error.
# bar graph of total time and pixels in each ROI
deltaPix = deltaPix[:,1:] # get rid of background columns
frameRate = getFrameRate()
rows,cols = deltaPix.shape
pixSums = np.sum(deltaPix, axis=0)
deltaPix[deltaPix>0]=1 # convert pixels to time moving
timeSums = np.sum(deltaPix, axis=0) / frameRate
f, (ax1, ax2) = plt.subplots(2, sharex=True)
ax1.bar(np.arange(cols) + 1, pixSums, align='center')
ax2.bar(np.arange(cols) + 1, timeSums, align='center')
plt.xlabel('ROI number', fontsize=18)
plt.xlim(0,cols+1)
ax1.set_ylabel('Locomotion \n(displaced pixels)', fontsize=18, va='center')
ax1.yaxis.labelpad = 25
ax2.set_ylabel('Locomotion \n(seconds with motion)', fontsize=18, va='center')
ax2.yaxis.labelpad = 25
f.set_facecolor('w')
plt.tick_params(axis='both', which='major', labelsize=18)
if cols < 21:
plt.xticks(np.arange(1, cols+1, 1))
else:
plt.xticks(np.arange(1, cols+1, 5))
plt.show()
Any ideas? Will I have to embed the matplotlib graphs in the interface?