Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么matplotlib会单独绘制图形,即使我已经将它们嵌入PyQt5 GUI中?_Python_Python 3.x_Matplotlib_Plot - Fatal编程技术网

Python 为什么matplotlib会单独绘制图形,即使我已经将它们嵌入PyQt5 GUI中?

Python 为什么matplotlib会单独绘制图形,即使我已经将它们嵌入PyQt5 GUI中?,python,python-3.x,matplotlib,plot,Python,Python 3.x,Matplotlib,Plot,在将Matplotlib绘图添加到PyQt5 GUI时,我遇到了这个问题。 请告诉我为什么图形窗口会为每个图形单独打开,而不是GUI绘图? 以下是我用来在PyQt5 GUI中可视化各种绘图的代码块: self.figure1 = {} self.canvas1 = {} ax1 = {} self.toolbar1 = {} row1 = 0 column1 = 0 for i in range(0,len

在将Matplotlib绘图添加到PyQt5 GUI时,我遇到了这个问题。 请告诉我为什么图形窗口会为每个图形单独打开,而不是GUI绘图?

以下是我用来在PyQt5 GUI中可视化各种绘图的代码块:

    self.figure1 = {}
    self.canvas1 = {}
    ax1 = {}
    self.toolbar1 = {}
    
    
    
    row1 = 0
    column1 = 0
    for i in range(0,len(Tf)):
      groupbox1[i] = QGroupBox("Patient {}".format(i+1))
      groupbox1[i].setMinimumWidth(350)
      groupbox1[i].setMinimumHeight(350)
      groupbox1[i].setFont(QtGui.QFont("Sanserif", 8))
      if i%3 == 0:
        row1+=1
        column1 = 0
      grid3.addWidget(groupbox1[i],row1,column1)
      column1 +=1
    
      vbox1[i] = QVBoxLayout()
      self.figure1[i] = plt.figure()
      
      self.canvas1[i] = FigureCanvas(self.figure1[i])
      self.toolbar1[i] = NavigationToolbar(self.canvas1[i], self.content4)
      ax1[i] = self.figure1[i].add_subplot(111)
      ax1[i].set_title("Time vs Drug concentration (Logarithmic) - Patient # {} - R2adj: {} - N : {}".format(i+1,round(r2adj_max[i],4),r2adj_final[i]))
      ax1[i].set_xlabel('Time')
      ax1[i].set_ylabel('Drug Concentration')

      ax1[i].plot(Tf[i], (np.log(Cf[i])), '.-',color='red', label='Original Values') 
      ax1[i].plot(c_test[i], b_pred[i], '*-',  color='blue', label='Predicted Values') 
      ax1[i].legend()
   
      self.canvas1[i].draw()
      vbox1[i].addWidget(self.toolbar1[i])
      vbox1[i].addWidget(self.canvas1[i]) 
      groupbox1[i].setLayout(vbox1[i])
    



你的帮助对我意义重大。提前感谢。

请单击带下划线的文本查看所附图像。