Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Milestone
Description
Bug report
Bug summary
There was a previous issue#12648 which noted a regression in Matplotlib which meant calling annotate with a nan position caused an error when using the commandplt.tight_layout()
. This issue was then closed by#12651, however with Matplotlib 3.0.2 I still am recieving an error with the following code, which I think should be functionally the same:
importmatplotlib.pyplotaspltfig,ax=plt.subplots()ax.annotate("",xy=(0,float('nan')))# If axis is set on then a ValueError is thrown when calculating ticks# If axis is set off then a RuntimeError: libpng signaled error is thrownax.set_axis_off()fig.savefig("bar.png",bbox_inches='tight')
Actual outcome
libpng warning: Image width is zero in IHDRlibpng warning: Image height is zero in IHDRlibpng error: Invalid IHDR dataTraceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/michael/conda/envs/nnpdf/lib/python3.7/site-packages/matplotlib/figure.py", line 2094, in savefig self.canvas.print_figure(fname, **kwargs) File "/Users/michael/conda/envs/nnpdf/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 2075, in print_figure **kwargs) File "/Users/michael/conda/envs/nnpdf/lib/python3.7/site-packages/matplotlib/backends/backend_agg.py", line 523, in print_png self.figure.dpi, metadata=metadata)RuntimeError: libpng signaled error
Expected outcome
I think this minimal example should just return an empty figure and ignore the annotation with NaN position. Maybe I'm mistaken but I would have thought it should be the same output as
plt.tight_layout()plt.savefig("bar.png")
which does work as per the#12651
Matplotlib version
- Operating system: OSX, but also tested on linux
- Matplotlib version: 3.0.2
- Matplotlib backend (
print(matplotlib.get_backend())
): TkAgg - Python version: 3.7.2
(conda installation)
Metadata
Metadata
Assignees
Labels
No labels