Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
justengel opened this issue Nov 25, 2015 · 2 comments
Closed

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

justengel opened this issue Nov 25, 2015 · 2 comments

Comments

@justengel
Copy link

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
@tacaswell tacaswell added this to the next bug fix release (2.0.1) milestone Nov 25, 2015
@tacaswell
Copy link
Member

While we sort this out, you should add a Qt-level callback in your application that sets fig.set_visible(False) when the splitter gets too narrow.

@QuLogic QuLogic modified the milestones: 2.0.1 (next bug fix release), 2.0.2 (next bug fix release) May 3, 2017
@tacaswell tacaswell modified the milestones: 2.1.1 (next bug fix release), 2.2 (next feature release) Oct 9, 2017
@anntzer
Copy link
Contributor

anntzer commented Apr 22, 2020

Zero-sized figures are now explicitly excluded by #16687.

@anntzer anntzer closed this as completed Apr 22, 2020
@story645 story645 removed this from the future releases milestone Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants