-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Matplotlib 3.2.1 savefig empty image when fig size matches data size exactly #17542
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
Comments
Furthermore, if you do |
Thanks for the quick response and work-around. Hopefully it will be possible to get to the underlying issue. I don't recall the origin of the pad and bbox options in this code, though I would note that it is surprising that not specifying the pad_inches and bbox_inches options results in no padding in this case. From the documentation, the default value for pad_inches is 0.1 inch. |
|
This was broken by #16734 which disables the draw methods on the renderer (because to compute the bounding boxes we don't need to actually draw turn the crank on the renderer methods, only the artist methods) but we never re-set the methods to their original values. This is not normally a problem as the tight bounding box is a different size that original size so the caching in matplotlib/lib/matplotlib/backends/backend_agg.py Lines 411 to 421 in 4356b67
I can see a bunch of hacky ways to fix this, but not sure which one is the best. |
It seems to me that |
The problem is that where we know if we have flagged it as |
Bug report
Bug summary
Saving a figure to an image file with the same pixel dimensions as data loaded with imshow does not work in 3.2.1, producing an empty image. If the dimensions are changed by even one pixel, normal behavior returns.
This bug appeared in 3.2.1 and I have confirmed that it does not occur with 3.1.1.
I noticed in the release notes for 3.2.0 that some changes were made to the default image interpolation; perhaps an unhandled condition was introduced here when no interpolation is required. However, I note that changing the interpolation mode had no effect on this bug.
Code for reproduction
Actual outcome

Expected outcome
Produced with matplotlib 3.1.1
Matplotlib version
print(matplotlib.get_backend())
): TkAggDefault system install on Arch linux package
python-matplotlib-3.2.1-1-x86_64
The text was updated successfully, but these errors were encountered: