You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bug here is assuming that DefaultSize still contained the values you printed earlier. This is subtle (and I missed it before), but what you are getting back from F.get_size_inches() is a view of the internal numpy array. When you set the new size, the internal array was updated, not replaced. This is much in the same vein as Python mutables, but taken a bit further than you are probably used to. Because the internal array was updated, the view (stored in DefaultSize) showed the new data as well. So, when you tried to set (what you thought was still) the original size, it was merely setting the current values back to itself. Therefore, no change.
So, to force DefaultSize to be immutable, just cast it as a tuple:
Once users sets a wrong figure size or something gets screwed (don't know the cause), a stacktrace like this is returned. Please improve the error message to provide more details about what has the user passed so bad to matplotlib. This is from mpl-1.2.1
File "/usr/lib64/python2.7/site-packages/matplotlib/figure.py", line 1362, in savefig
self.canvas.print_figure(_args, *_kwargs)
File "/usr/lib64/python2.7/site-packages/matplotlib/backend_bases.py", line 2096, in print_figure
**kwargs)
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 492, in print_png
FigureCanvasAgg.draw(self)
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 435, in draw
self.renderer = self.get_renderer()
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 454, in get_renderer
self.renderer = RendererAgg(w, h, self.figure.dpi)
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 85, in init
self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False)
ValueError: width and height must each be below 32768
The text was updated successfully, but these errors were encountered:
In relation to the stacktrace I think the source problem is that I set figsize to [ 11.2 520.8]. There should be a sanity check in figure.set_size_inches() so that matplotlib does not crash much later while saving a figure. It's too late.
It appeared in the thread http://matplotlib.1069221.n5.nabble.com/RendererAgg-int-width-int-height-dpi-debug-False-ValueError-width-and-height-must-each-be-below-32768-td27756.html that figure.get_size_inches() returns unexpetedly a view of a numpy array. Views behave unexpectedly to users not familiar with numpy.
So, to force DefaultSize to be immutable, just cast it as a tuple:
A link to get_size_inches() should be introduced from set_size_inches(), that is where users are likely to hit this issue.
http://matplotlib.org/api/figure_api.html?highlight=set_size_inches#matplotlib.figure.Figure.set_size_inches
Once users sets a wrong figure size or something gets screwed (don't know the cause), a stacktrace like this is returned. Please improve the error message to provide more details about what has the user passed so bad to matplotlib. This is from mpl-1.2.1
File "/usr/lib64/python2.7/site-packages/matplotlib/figure.py", line 1362, in savefig
self.canvas.print_figure(_args, *_kwargs)
File "/usr/lib64/python2.7/site-packages/matplotlib/backend_bases.py", line 2096, in print_figure
**kwargs)
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 492, in print_png
FigureCanvasAgg.draw(self)
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 435, in draw
self.renderer = self.get_renderer()
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 454, in get_renderer
self.renderer = RendererAgg(w, h, self.figure.dpi)
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 85, in init
self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False)
ValueError: width and height must each be below 32768
The text was updated successfully, but these errors were encountered: