<p dir="auto">I have two matplotlib figures inside a QSplitter.<br>
When I move the Splitter to the edge (the figure disapear then), the code crashes.</p>
<p dir="auto">the error I get is</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;C:\Python36\lib\site-packages\matplotlib\backends\backend_qt5.py&quot;, line 397, in resizeEvent
    self.figure.set_size_inches(winch, hinch, forward=False)
  File &quot;C:\Python36\lib\site-packages\matplotlib\figure.py&quot;, line 902, in set_size_inches
    raise ValueError(f'figure size must be positive finite not {size}')
ValueError: figure size must be positive finite not [0.   6.12]"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "C:\Python36\lib\site-packages\matplotlib\backends\backend_qt5.py", line 397, in resizeEvent
    self.figure.set_size_inches(winch, hinch, forward=False)
  File "C:\Python36\lib\site-packages\matplotlib\figure.py", line 902, in set_size_inches
    raise ValueError(f'figure size must be positive finite not {size}')
ValueError: figure size must be positive finite not [0.   6.12]
</code></pre></div>
<p dir="auto">This wasn't an issue before, when only one of the two side of the Qsplitter was on the screen, my code did not crash. When I pull the splitter to the center again, the figure reappear properly.</p>
<p dir="auto">here a minimal example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from PyQt5.QtGui import *
from PyQt5.QtWidgets import  *
from PyQt5.QtCore import * 
import sys
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas

class window(QMainWindow):
    def __init__(self, parent=None):
        super(window, self).__init__()
        self.parent = parent

        self.centralWidget = QWidget()
        self.setCentralWidget(self.centralWidget)

        self.mainHBOX_param_scene = QHBoxLayout()

        self.mainsplitter = QSplitter(Qt.Horizontal)
        V1 = Viewer()
        V2 = Viewer()
        self.mainsplitter.addWidget(V1)
        self.mainsplitter.addWidget(V2)


        self.mainHBOX_param_scene.addWidget(self.mainsplitter)
        self.centralWidget.setLayout(self.mainHBOX_param_scene)


class Viewer(QGraphicsView):
    def __init__(self, parent=None):
        super( Viewer, self).__init__(parent)
        self.parent = parent
        self.setStyleSheet(&quot;border: 0px&quot;)
        self.scene = QGraphicsScene(self)
        self.setScene(self.scene)
        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)

        self.axes_Delay = self.figure.add_subplot(1, 1,1)
        self.axes_Delay.set_title(&quot;Title&quot;)

        # self.canvas.setGeometry(0, 0, 1600, 500 )
        layout = QVBoxLayout()
        layout.addWidget(self.canvas)
        self.setLayout(layout)
        self.canvas.show()


    def closeEvent(self, event):
        plt.close(self.figure)


def main():
    app = QApplication(sys.argv)
    ex = window(app)
    ex.show()
    sys.exit(app.exec_( ))


if __name__ == '__main__':
    main()"><pre class="notranslate"><code class="notranslate">from PyQt5.QtGui import *
from PyQt5.QtWidgets import  *
from PyQt5.QtCore import * 
import sys
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas

class window(QMainWindow):
    def __init__(self, parent=None):
        super(window, self).__init__()
        self.parent = parent

        self.centralWidget = QWidget()
        self.setCentralWidget(self.centralWidget)

        self.mainHBOX_param_scene = QHBoxLayout()

        self.mainsplitter = QSplitter(Qt.Horizontal)
        V1 = Viewer()
        V2 = Viewer()
        self.mainsplitter.addWidget(V1)
        self.mainsplitter.addWidget(V2)


        self.mainHBOX_param_scene.addWidget(self.mainsplitter)
        self.centralWidget.setLayout(self.mainHBOX_param_scene)


class Viewer(QGraphicsView):
    def __init__(self, parent=None):
        super( Viewer, self).__init__(parent)
        self.parent = parent
        self.setStyleSheet("border: 0px")
        self.scene = QGraphicsScene(self)
        self.setScene(self.scene)
        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)

        self.axes_Delay = self.figure.add_subplot(1, 1,1)
        self.axes_Delay.set_title("Title")

        # self.canvas.setGeometry(0, 0, 1600, 500 )
        layout = QVBoxLayout()
        layout.addWidget(self.canvas)
        self.setLayout(layout)
        self.canvas.show()


    def closeEvent(self, event):
        plt.close(self.figure)


def main():
    app = QApplication(sys.argv)
    ex = window(app)
    ex.show()
    sys.exit(app.exec_( ))


if __name__ == '__main__':
    main()
</code></pre></div>
<p dir="auto">How can I avoid this error?<br>
I use matplotlib version 3.2.1 by the way.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/12172752/84269886-266ee780-ab2a-11ea-8e1e-f1441e0b0737.png"><img src="https://user-images.githubusercontent.com/12172752/84269886-266ee780-ab2a-11ea-8e1e-f1441e0b0737.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong><br>
I use matplotlib + PyQt5. The figure is placed inside a QSplitter (a standard Qt widget that consists of several vertical or horizontal parts which can be resized by handles between those parts) . When a part of QSplitter shrinks to a zero size it automatically resizes the widget it contains. Matplotlib raises an error as was mentioned in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="576427349" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/16687" data-hovercard-type="issue" data-hovercard-url="/matplotlib/matplotlib/issues/16687/hovercard" href="https://github.com/matplotlib/matplotlib/issues/16687">#16687</a>.</p>

<p dir="auto"><strong>Actual outcome</strong></p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ValueError: figure size must be positive finite not [17.45  0.  ]"><pre class="notranslate"><code class="notranslate">ValueError: figure size must be positive finite not [17.45  0.  ]
</code></pre></div>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto">A zero height figure.</p>


<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system: Kubuntu 19.10</li>
<li>Matplotlib version: &gt;=3.2.0 (installed by pip)</li>
<li>Matplotlib backend: Qt5Agg</li>
<li>Python version: 3.6.9</li>
<li>Other libraries: PyQt5</li>
</ul>