title: PyQt - FigureCanvas is not displayed (Navigation Toolbar does)
body: <p>I’m trying to implement Drag and Drop on a FigureCanvas. That means, I want to drag the text from the left layout and drop it to the canvas on the right.
  Unfortunately, even though the Navigation Toolbar is displayed, the canvas is not.</p>
  
  <p>Before creating the Create_Canvas class to implement the Drag and Drop, I could display everything with no problem. I’m new to programming, I’m not sure if I wrote the Create_Canvas class right.</p>
  
  <p>I also post a picture:</p>
  
  <p><a href="https://i.stack.imgur.com/Eqamb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Eqamb.jpg" alt="enter image description here"></a></p>
  
  <p>In case you don’t have matplotlib installed.</p>
  
  <p>Thanks in advance!</p>
  
  <pre><code>import sys, time
  
  from PyQt5.QtWidgets import *
  from PyQt5.QtGui import *
  from PyQt5.QtCore import *
  
  from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
  from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
  from matplotlib.figure import Figure
  
  import matplotlib.pyplot as plt
  import matplotlib.cm as cm
  import matplotlib.colors as mcolors
  import matplotlib.colorbar as mcolorbar
  
  import numpy as np
  import pylab as pl
  
  import random
  
  
  class Example(QMainWindow):
      def __init__(self):
          super().__init__()
          self.initUI()
  
      def initUI(self):
          self.central_widget = QWidget()
          self.setCentralWidget(self.central_widget)
          self.editLayout = QWidget()
          self.edit = QLineEdit('chfghfghf', self)
          self.edit.setDragEnabled(True)
  
          self.left_layout = QVBoxLayout()
          self.left_layout.addWidget(self.edit)
  
          self.editLayout.setLayout(self.left_layout)
  
          #Create the right layout that contains the plot canvas.    
          self.plotLayout = QWidget();
  
          canvas = Create_Canvas(self)       
  
          self.button = QPushButton('Plot')
  
          # set the layout
          self.right_layout = QVBoxLayout()
          self.right_layout.addWidget(canvas)
          self.right_layout.addWidget(self.button)
  
          self.plotLayout.setLayout(self.right_layout)
  
          splitter_filebrowser = QSplitter(Qt.Horizontal)
          splitter_filebrowser.addWidget(self.editLayout)
          splitter_filebrowser.addWidget(self.plotLayout)
          splitter_filebrowser.setStretchFactor(1, 1)
  
          hbox = QHBoxLayout(self)
          hbox.addWidget(splitter_filebrowser)
  
          self.centralWidget().setLayout(hbox)
  
          self.setWindowTitle('Simple drag &amp; drop')
          self.setGeometry(750, 100, 600, 500)
  
  
  class Create_Canvas(QWidget):
      def __init__(self, parent):
          super().__init__(parent)
          self.setAcceptDrops(True)
  
          figure = plt.figure()
          canvas = FigureCanvas(figure)
          toolbar = NavigationToolbar(canvas, self)
  
          self.right_layout = QVBoxLayout()
          self.right_layout.addWidget(canvas)
          self.right_layout.addWidget(toolbar)
  
      def dragEnterEvent(self, e):
          print('entering')
          if e.mimeData().hasFormat('text/plain'):
              e.accept()
          else:
              e.ignore()
  
      def dragMoveEvent(self, e):
          print('drag moving')
  
      def dropEvent(self, e):
          print("dropped")
  
  
  if __name__ == '__main__':
  
      app = QApplication(sys.argv)
      ex = Example()
      ex.show()
      app.exec_()      
  </code></pre>