Repository: silx-kit/silx
Issue: issue with StackViewMainWindow

If you have an instance of StackViewMainWindow rendered on a small window (small width) with **matplotlib** and if you activate the colorbar then you end up with the following issue:

``` bash
  File "/mnt/multipath-shares/scisoft/darfix/payno/venv/lib/python3.8/site-packages/silx/gui/plot/backends/BackendMatplotlib.py", line 1376, in __deferredReplot
    self.replot()
  File "/mnt/multipath-shares/scisoft/darfix/payno/venv/lib/python3.8/site-packages/silx/gui/plot/backends/BackendMatplotlib.py", line 1549, in replot
    self.draw()
  File "/mnt/multipath-shares/scisoft/darfix/payno/venv/lib/python3.8/site-packages/silx/gui/plot/backends/BackendMatplotlib.py", line 1498, in draw
    FigureCanvasQTAgg.draw(self)
  File "/mnt/multipath-shares/scisoft/darfix/payno/venv/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 436, in draw
    self.figure.draw(self.renderer)
  File "/mnt/multipath-shares/scisoft/darfix/payno/venv/lib/python3.8/site-packages/matplotlib/artist.py", line 74, in draw_wrapper
    result = draw(artist, renderer, *args, **kwargs)
  File "/mnt/multipath-shares/scisoft/darfix/payno/venv/lib/python3.8/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer)
  File "/mnt/multipath-shares/scisoft/darfix/payno/venv/lib/python3.8/site-packages/matplotlib/figure.py", line 2789, in draw
    artists = self._get_draw_artists(renderer)
  File "/mnt/multipath-shares/scisoft/darfix/payno/venv/lib/python3.8/site-packages/matplotlib/figure.py", line 235, in _get_draw_artists
    pos = locator(ax, renderer)
  File "/mnt/multipath-shares/scisoft/darfix/payno/venv/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 119, in __call__
    self._transform - ax.figure.transSubfigure)
  File "/mnt/multipath-shares/scisoft/darfix/payno/venv/lib/python3.8/site-packages/matplotlib/transforms.py", line 1470, in __sub__
    return self + other.inverted()
  File "/mnt/multipath-shares/scisoft/darfix/payno/venv/lib/python3.8/site-packages/matplotlib/transforms.py", line 1890, in inverted
    self._inverted = Affine2D(inv(mtx), shorthand_name=shorthand_name)
  File "<__array_function__ internals>", line 180, in inv
  File "/mnt/multipath-shares/scisoft/darfix/payno/venv/lib/python3.8/site-packages/numpy/linalg/linalg.py", line 552, in inv
    ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj)
  File "/mnt/multipath-shares/scisoft/darfix/payno/venv/lib/python3.8/site-packages/numpy/linalg/linalg.py", line 89, in _raise_linalgerror_singular
    raise LinAlgError("Singular matrix")
numpy.linalg.LinAlgError: Singular matrix
```

We had a look with @t20100 and it turned out the plot widget end up with a width equal to zero (colorbar and mask widget taking all the space) and matplotlib cannot display it.

a quick fix would be to specify the `ColumnMinimumWidth` of the `PlotWindow`. Like on this patch: 
[patch_stackmainwindow.txt](https://github.com/silx-kit/silx/files/10022588/patch_stackmainwindow.txt)


To reproduce you can run the following code, reduce the size of the window and click on the 'mask' icon

``` python
from silx.gui import qt
from silx.gui.plot.StackView import StackViewMainWindow
import numpy

qapp = qt.QApplication([])

widget = StackViewMainWindow()
widget.setStack(
    numpy.arange(100*100*100).reshape((100, 100, 100))
)
widget.show()

qapp.exec_()

```

Changed files:
src/silx/gui/plot/backends/BackendMatplotlib.py

diff --git a/src/silx/gui/plot/backends/BackendMatplotlib.py b/src/silx/gui/plot/backends/BackendMatplotlib.py
index 8610ed175..1b31582e3 100755
--- a/src/silx/gui/plot/backends/BackendMatplotlib.py
+++ b/src/silx/gui/plot/backends/BackendMatplotlib.py
@@ -1485,6 +1485,9 @@ class BackendMatplotlibQt(BackendMatplotlib, FigureCanvasQTAgg):
 
         This is directly called by matplotlib for widget resize.
         """
+        if self.size().isEmpty():
+            return  # Skip rendering of 0-sized canvas
+
         self.updateZOrder()
 
         # Starting with mpl 2.1.0, toggling autoscale raises a ValueError