title: Home button in Matplotlib 2.1.0 navigation toolbar embeded in pyqt5 window, it no longer works correctly
body: <p>I embedded a matplotlib in a window maked in qtdesigner, pyqt5. I have 3 files</p>
  
  <p>The window:</p>
  
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  
  class Ui_MplMainWindow(object):
      def setupUi(self, MplMainWindow):
          MplMainWindow.setObjectName("MplMainWindow")
          MplMainWindow.resize(628, 416)
          self.centralwidget = QtWidgets.QWidget(MplMainWindow)
          self.centralwidget.setObjectName("centralwidget")
          self.gridLayout_2 = QtWidgets.QGridLayout(self.centralwidget)
          self.gridLayout_2.setObjectName("gridLayout_2")
          self.mpl = MplWidgetTest(self.centralwidget)
          sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
          sizePolicy.setHorizontalStretch(0)
          sizePolicy.setVerticalStretch(0)
          sizePolicy.setHeightForWidth(self.mpl.sizePolicy().hasHeightForWidth())
          self.mpl.setSizePolicy(sizePolicy)
          self.mpl.setObjectName("mpl")
          self.gridLayout_2.addWidget(self.mpl, 0, 0, 1, 1)
          self.groupBox = QtWidgets.QGroupBox(self.centralwidget)
          self.groupBox.setMaximumSize(QtCore.QSize(95, 16777215))
          self.groupBox.setObjectName("groupBox")
          self.gridLayout = QtWidgets.QGridLayout(self.groupBox)
          self.gridLayout.setObjectName("gridLayout")
          self.buttonDrawDate = QtWidgets.QPushButton(self.groupBox)
          self.buttonDrawDate.setMaximumSize(QtCore.QSize(75, 16777215))
          self.buttonDrawDate.setObjectName("buttonDrawDate")
          self.gridLayout.addWidget(self.buttonDrawDate, 0, 0, 1, 1)
          self.buttonErase = QtWidgets.QPushButton(self.groupBox)
          self.buttonErase.setMaximumSize(QtCore.QSize(75, 16777215))
          self.buttonErase.setObjectName("buttonErase")
          self.gridLayout.addWidget(self.buttonErase, 1, 0, 1, 1)
          spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
          self.gridLayout.addItem(spacerItem, 2, 0, 1, 1)
          self.gridLayout_2.addWidget(self.groupBox, 0, 1, 1, 1)
          MplMainWindow.setCentralWidget(self.centralwidget)
          self.menubar = QtWidgets.QMenuBar(MplMainWindow)
          self.menubar.setGeometry(QtCore.QRect(0, 0, 628, 21))
          self.menubar.setObjectName("menubar")
          MplMainWindow.setMenuBar(self.menubar)
          self.statusbar = QtWidgets.QStatusBar(MplMainWindow)
          self.statusbar.setObjectName("statusbar")
          MplMainWindow.setStatusBar(self.statusbar)
  
          self.retranslateUi(MplMainWindow)
          QtCore.QMetaObject.connectSlotsByName(MplMainWindow)
  
      def retranslateUi(self, MplMainWindow):
          _translate = QtCore.QCoreApplication.translate
          MplMainWindow.setWindowTitle(_translate("MplMainWindow", "MainWindow"))
          self.groupBox.setTitle(_translate("MplMainWindow", "GroupBox"))
          self.buttonDrawDate.setText(_translate("MplMainWindow", "Draw"))
          self.buttonErase.setText(_translate("MplMainWindow", "Erase"))
  
  from mplwidgettest import MplWidgetTest
  </code></pre>
  
  <p>The Matplot widget class:</p>
  
  <pre><code>from PyQt5.QtWidgets import QSizePolicy, QWidget, QVBoxLayout
  from matplotlib.figure import Figure
  from matplotlib.backends.backend_qt5agg import (
      FigureCanvasQTAgg as FigureCanvas,
      NavigationToolbar2QT as NavigationToolbar)
  
  
  class MplCanvas(FigureCanvas):
      """Class to represent the FigureCanvas widget"""
      def __init__(self):
          # setup Matplotlib Figure and Axis
          self.fig = Figure()
          self.ax = self.fig.add_subplot(111)
          # initialization of the canvas
          FigureCanvas.__init__(self, self.fig)
          # we define the widget as expandable
          FigureCanvas.setSizePolicy(self,
                                     QSizePolicy.Expanding,
                                     QSizePolicy.Expanding)
          # notify the system of updated policy
          FigureCanvas.updateGeometry(self)
  class MplWidgetTest(QWidget):
      """Widget defined in Qt Designer"""
      def __init__(self, parent = None):
          # initialization of Qt MainWindow widget
          QWidget.__init__(self, parent)
          # set the canvas to the Matplotlib widget
          self.canvas = MplCanvas()
          # create a NavigatioToolbar
          self.ntb=NavigationToolbar(self.canvas,self)
          # create a vertical box layout
          self.vbl = QVBoxLayout()
          # add mpl widget to vertical box
          self.vbl.addWidget(self.canvas)
          # add NavigationToolBar to vertical box
          self.vbl.addWidget(self.ntb)
          # set the layout to th vertical box
          self.setLayout(self.vbl)
  </code></pre>
  
  <p>And the main file that call others:</p>
  
  <pre><code>import sys
  from IHMDrawDates import Ui_MplMainWindow
  from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget
  import numpy as np
  import datetime
  
  
  class DesignerMainWindow(QMainWindow, Ui_MplMainWindow):
      def __init__(self, parent = None):
          super(DesignerMainWindow, self).__init__(parent)
          self.setupUi(self)
          # connect the signals with the slots
          self.buttonDrawDate.clicked.connect(self.drawDate)
          self.buttonErase.clicked.connect(self.eraseDate)
      def drawDate(self):
  #        base = datetime.datetime(2018, 1, 1)
  #        x = np.array([base + datetime.timedelta(hours=i) for i in range(24)])
  #        y = np.random.rand(len(x))
          x = np.arange(0,100,0.1)
          y = np.sin(x)
          self.mpl.canvas.ax.plot(x,y)
          self.mpl.canvas.ax.relim()
          self.mpl.canvas.ax.autoscale(True)
          self.mpl.canvas.draw()
      def eraseDate(self):
          self.mpl.canvas.ax.clear()
          self.mpl.canvas.draw()
  
  
  if __name__ == '__main__':
      app=0
      app = QApplication(sys.argv)
      dmw = DesignerMainWindow()
      # show it
      dmw.show() 
      sys.exit(app.exec_())    
  </code></pre>
  
  <p>After update to matplotlib 2.1.0, the home button does not work correctly. It always return to the inicial clean axes. Example:</p>
  
  <p>1.-Before click in drawing button:
  <a href="https://i.stack.imgur.com/8UI9F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8UI9F.png" alt="enter image description here"></a></p>
  
  <p>2.-Click in draw button:
  <a href="https://i.stack.imgur.com/c3RvN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c3RvN.png" alt="enter image description here"></a></p>
  
  <p>3.-Click in zoom:
  <a href="https://i.stack.imgur.com/Sq1QQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Sq1QQ.png" alt="enter image description here"></a></p>
  
  <p>4.-Click in home:
  <a href="https://i.stack.imgur.com/x0pTO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x0pTO.png" alt="enter image description here"></a></p>
  
  <p>before the update, pressing the button HOME it returned to the image number 2, now with matplotlib 2.1.0 it returned to image 4. Any idea.</p>
  
  <p>When I add:</p>
  
  <pre><code>def drawDate(self):
      x = np.arange(0,100,0.1)
      y = np.sin(x)
      self.mpl.canvas.ax.plot(x,y)
      self.mpl.canvas.ax.relim()
      self.mpl.canvas.ax.autoscale(True)
      self.mpl.ntb.update()
      self.mpl.canvas.draw()
  
  def eraseDate(self):
      self.mpl.canvas.ax.clear()
      self.mpl.ntb.update()
      self.mpl.canvas.draw()
  </code></pre>
  
  <p>Then occurs:
  <a href="https://i.stack.imgur.com/2PWkL.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2PWkL.gif" alt="enter image description here"></a></p>