这是我的GUI部分,我在另一个脚本中调用该函数,该部分应该显示我的图形。我会发布整个事情,但它很长。
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()
这两个motionTools函数都使用数据(timeStamps和deltaPix是数组切片,fps是每秒帧数的整数)来生成不同的图形。以下是其中一个(barTimeInROI)的示例 - 都会导致此灰屏错误。
# 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()
有什么想法吗?我是否必须在界面中嵌入matplotlib图形?