title: Edge labels of networkx graph don't show in PyQt embedded matplotlib
body: <p>I have networkx directed graph that are displayed in a PyQt5 application which are working perfectly fine.
  I am now trying to add labels to the edge for some conveniency, but can't manage to make them appear.</p>
  <p>Below is a dummy application to replicate the issue:</p>
  <pre><code>import sys
  from PyQt5 import QtCore, QtWidgets
  from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
  from matplotlib.pyplot import Figure
  import networkx as nx
  
  
  class data_tab(QtWidgets.QWidget):
  
      def __init__(self, parent, title):
  
          QtWidgets.QWidget.__init__(self, parent)
  
          self.data_tab_glayout = QtWidgets.QGridLayout(self)
          self.canvas = FigureCanvas(Figure(figsize=(5, 3)))
          self.canvas_vlayout = QtWidgets.QVBoxLayout(self.canvas)
          self.data_tab_glayout.addWidget(self.canvas, 0, 0, 2, 1)
  
          self.axe = self.canvas.figure.add_subplot(111)
          self.canvas.figure.subplots_adjust(left=0.025, top=0.965, bottom=0.040, right=0.975)
          # add the tab to the parent
          parent.addTab(self, &quot;&quot;)
  
          # set text name
          parent.setTabText(parent.indexOf(self), title)
  
  
  class spec_writer(QtWidgets.QMainWindow):
  
      def __init__(self, parent=None):
          QtWidgets.QMainWindow.__init__(self, parent)
  
          self.showMaximized()
  
          self.centralwidget = QtWidgets.QWidget(self)
          self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
          self.core_tab = QtWidgets.QTabWidget(self.centralwidget)
          self.verticalLayout.addWidget(self.core_tab)
          self.add_tab_btn = QtWidgets.QPushButton(self.centralwidget)
          self.verticalLayout.addWidget(self.add_tab_btn)
          self.refresh_tab_btn = QtWidgets.QPushButton(self.centralwidget)
          self.verticalLayout.addWidget(self.refresh_tab_btn)
          self.setCentralWidget(self.centralwidget)
  
          self.add_tab_btn.setText(&quot;Add Tab&quot;)
          self.refresh_tab_btn.setText(&quot;Refresh Tabs&quot;)
  
          self.core_tab.setEnabled(True)
          self.core_tab.setTabShape(QtWidgets.QTabWidget.Rounded)
          self.core_tab.setElideMode(QtCore.Qt.ElideNone)
          self.core_tab.setDocumentMode(False)
          self.core_tab.setTabsClosable(True)
          self.core_tab.setMovable(True)
          self.core_tab.setTabBarAutoHide(False)
  
          self.tab_counter = 0
  
          self.random_tabs = [(&quot;a&quot;, [&quot;b&quot;, &quot;c&quot;]),
                              (&quot;d&quot;, [&quot;e&quot;, &quot;f&quot;, &quot;g&quot;]),
                              (&quot;h&quot;, [&quot;i&quot;, &quot;j&quot;, &quot;k&quot;, &quot;l&quot;]),
                              (&quot;m&quot;, [&quot;n&quot;]),
                              (&quot;o&quot;, [&quot;p&quot;, &quot;q&quot;]),
                              (&quot;r&quot;, [&quot;s&quot;, &quot;t&quot;, &quot;u&quot;, &quot;v&quot;, &quot;w&quot;, &quot;x&quot;, &quot;y&quot;, &quot;z&quot;])]
  
          self.add_tab_btn.clicked.connect(self.openRandomTab)
          self.refresh_tab_btn.clicked.connect(self.refreshAllTabs)
  
      def openRandomTab(self):
  
          tab = data_tab(self.core_tab, &quot;test &quot; + str(self.tab_counter))
          self._drawDataGraph(self.tab_counter % len(self.random_tabs), tab)
          self.tab_counter += 1
  
          self.core_tab.setCurrentIndex(self.core_tab.indexOf(tab))
  
  
      def _drawDataGraph(self, tabNb, dataWidget):
          dataWidget.axe.cla()
  
          # 1. draw graph
          producer = self.random_tabs[tabNb][0]
          consumers = self.random_tabs[tabNb][1]
  
          color_map = []
          DG = nx.DiGraph()
          for cons in consumers:
              DG.add_edge(producer, cons, label=&quot;labeltest1&quot;)
          for i in range(len(DG.nodes())):
              if i &lt; 1 + len(consumers):
                  color_map.append(&quot;#DCE46F&quot;)
              else:
                  color_map.append(&quot;#6FA2E4&quot;)
          pos = nx.shell_layout(DG)
          labels = nx.get_edge_attributes(DG, 'label')
          nx.draw(DG, pos, node_color=color_map, with_labels=True, font_size=8, node_size=1000, node_shape='o', ax= dataWidget.axe)
          nx.draw_networkx_edge_labels(DG, pos, edge_labels=labels)
          dataWidget.canvas.draw()
  
  
      def refreshAllTabs(self):
  
          # loop through all pages and associated to get
          for tab_index in range(self.core_tab.count()):
              data_tab_widget = self.core_tab.widget(tab_index)
  
              # draw graph
              self._drawDataGraph(tab_index % len(self.random_tabs), data_tab_widget)
  
  
  
  
  sys.argv = ['']
  app = QtWidgets.QApplication(sys.argv)
  cbtc_spec_writer = spec_writer()
  cbtc_spec_writer.show()
  app.exec_()
  </code></pre>
  <p>I don't know what holds the labels to show, but when I execute the same code not embedded in a pyqt5 application (so directly with a plt.show()), it works properly. So I guess something is missing from my canvas setup.</p>
  <p>EDIT : below is what I want to obtain, but embedded in PyQt5 application. Currently the label &quot;labeltest1&quot; won't show</p>
  <p><a href="https://i.stack.imgur.com/OPjdb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OPjdb.png" alt="enter image description here" /></a></p>