Skip to content

LinAlgError on FigureCanvasQTAgg.draw when size == 0 #5563

Closed
@justengel

Description

@justengel

This isn't really a huge issue. It is a rare case that I can fix with a try except in the canvas draw method.

I have an animation running in my PySide GUI where the plot is inside a splitter. When the user drags the splitter to hide the plot I get a constant stream of errors. Draw doesn't work when the Canvas has either width == 0 or height == 0. If there is no height, width, or the canvas is not visible then the plot shouldn't try to draw at all.

File "site-packages\matplotlib\backends\backend_qt5.py", line 338, in resizeEvent
    self.draw()
  File "site-packages\matplotlib\backends\backend_qt5agg.py", line 148, in draw
    FigureCanvasAgg.draw(self)
  File "site-packages\matplotlib\backends\backend_agg.py", line 469, in draw
    self.figure.draw(self.renderer)
  File "site-packages\matplotlib\artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "site-packages\matplotlib\figure.py", line 1017, in draw
    self.tight_layout(renderer, **self._tight_parameters)
  File "site-packages\matplotlib\figure.py", line 1663, in tight_layout
    rect=rect)
  File "site-packages\matplotlib\tight_layout.py", line 352, in get_tight_layout_figure
    pad=pad, h_pad=h_pad, w_pad=w_pad)
  File "site-packages\matplotlib\tight_layout.py", line 131, in auto_adjust_subplotpars
    fig.transFigure.inverted())
  File "site-packages\matplotlib\transforms.py", line 1728, in inverted
    self._inverted = Affine2D(inv(mtx), shorthand_name=shorthand_name)
  File "site-packages\numpy\linalg\linalg.py", line 520, in inv
    ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj)
  File "site-packages\numpy\linalg\linalg.py", line 90, in _raise_linalgerror_singular
    raise LinAlgError("Singular matrix")
LinAlgError: Singular matrix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions