Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

calling annotate with nan values for the position still gives error after 3.0.2 #13276

Closed
Milestone
@wilsonmr

Description

@wilsonmr

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp