我在尝试从PyQt GUI调用matplotlib图形时遇到了一个问题。图形本身显示得很好,但它们一出现,我就在GUI和图形后面看到一个丑陋的灰色空白屏幕。在关闭GUI之前,这不会消失。你知道吗
这是我的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图吗?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐