Title: Regression when calling annotate with nan values for the position · Issue #12648 · matplotlib/matplotlib · GitHub
Open Graph Title: Regression when calling annotate with nan values for the position · Issue #12648 · matplotlib/matplotlib
X Title: Regression when calling annotate with nan values for the position · Issue #12648 · matplotlib/matplotlib
Description: The following code: import matplotlib.pyplot as plt plt.annotate('X', (0, float('nan'))) plt.tight_layout() plt.savefig('crash.png') raises an exception when using matplotlib 3, including 3.0.1. It works fine with matplotlib 2. /tmp/mpl3...
Open Graph Description: The following code: import matplotlib.pyplot as plt plt.annotate('X', (0, float('nan'))) plt.tight_layout() plt.savefig('crash.png') raises an exception when using matplotlib 3, including 3.0.1. It...
X Description: The following code: import matplotlib.pyplot as plt plt.annotate('X', (0, float('nan'))) plt.tight_layout() plt.savefig('crash.png') raises an exception when using matplotli...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/12648
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression when calling annotate with nan values for the position","articleBody":"The following code:\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nplt.annotate('X', (0, float('nan')))\r\nplt.tight_layout()\r\nplt.savefig('crash.png')\r\n```\r\nraises an exception when using matplotlib 3, including 3.0.1.\r\nIt works fine with matplotlib 2.\r\n\r\n```python-traceback\r\n/tmp/mpl3/lib/python3.7/site-packages/numpy/core/fromnumeric.py:83: RuntimeWarning: invalid value encountered in reduce\r\n return ufunc.reduce(obj, axis, dtype, out, **passkwargs)\r\n/tmp/mpl3/lib/python3.7/site-packages/numpy/core/_methods.py:32: RuntimeWarning: invalid value encountered in reduce\r\n return umr_minimum(a, axis, None, out, keepdims, initial)\r\n/tmp/mpl3/lib/python3.7/site-packages/numpy/core/_methods.py:28: RuntimeWarning: invalid value encountered in reduce\r\n return umr_maximum(a, axis, None, out, keepdims, initial)\r\nTraceback (most recent call last):\r\n File \"mplbug.py\", line 5, in \u003cmodule\u003e\r\n plt.savefig('crash.png')\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/pyplot.py\", line 689, in savefig\r\n res = fig.savefig(*args, **kwargs)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/figure.py\", line 2094, in savefig\r\n self.canvas.print_figure(fname, **kwargs)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/backends/backend_qt5agg.py\", line 88, in print_figure\r\n super().print_figure(*args, **kwargs)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/backend_bases.py\", line 2075, in print_figure\r\n **kwargs)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/backends/backend_agg.py\", line 510, in print_png\r\n FigureCanvasAgg.draw(self)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/backends/backend_agg.py\", line 402, in draw\r\n self.figure.draw(self.renderer)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/artist.py\", line 50, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/figure.py\", line 1649, in draw\r\n renderer, self, artists, self.suppressComposite)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/image.py\", line 138, in _draw_list_compositing_images\r\n a.draw(renderer)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/artist.py\", line 50, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/axes/_base.py\", line 2610, in draw\r\n mimage._draw_list_compositing_images(renderer, self, artists)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/image.py\", line 138, in _draw_list_compositing_images\r\n a.draw(renderer)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/artist.py\", line 50, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/axis.py\", line 1185, in draw\r\n ticks_to_draw = self._update_ticks(renderer)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/axis.py\", line 1023, in _update_ticks\r\n tick_tups = list(self.iter_ticks()) # iter_ticks calls the locator\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/axis.py\", line 967, in iter_ticks\r\n majorLocs = self.major.locator()\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/ticker.py\", line 1985, in __call__\r\n return self.tick_values(vmin, vmax)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/ticker.py\", line 1993, in tick_values\r\n locs = self._raw_ticks(vmin, vmax)\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/ticker.py\", line 1932, in _raw_ticks\r\n nbins = np.clip(self.axis.get_tick_space(),\r\n File \"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/axis.py\", line 2159, in get_tick_space\r\n return int(np.floor(length / size))\r\nValueError: cannot convert float NaN to integer\r\n```\r\n\r\n\r\nBased on the traceback, the following issues might be related:\r\n\r\n#10360 (likely this is a duplicate)\r\n#11386\r\n#6789\r\n\r\nThe snippet has been tested on brand new conda environments with the defaults\r\nchannel.\r\n\r\n\u003cdetails\u003e\r\n\u003csummary\u003eMatplotlib 3 env \u003c/summary\u003e\r\n\r\n```\r\n$ conda create -p /tmp/mpl3 matplotlib=3 --yes\r\nSolving environment: done\r\n\r\n## Package Plan ##\r\n\r\n environment location: /tmp/mpl3\r\n\r\n added / updated specs: \r\n - matplotlib=3\r\n\r\n\r\nThe following packages will be downloaded:\r\n\r\n package | build\r\n ---------------------------|-----------------\r\n matplotlib-3.0.1 | py37h5429711_0 6.6 MB\r\n\r\nThe following NEW packages will be INSTALLED:\r\n\r\n blas: 1.0-mkl \r\n ca-certificates: 2018.03.07-0 \r\n certifi: 2018.10.15-py37_0 \r\n cycler: 0.10.0-py37_0 \r\n dbus: 1.13.2-h714fa37_1 \r\n expat: 2.2.6-he6710b0_0 \r\n fontconfig: 2.13.0-h9420a91_0 \r\n freetype: 2.9.1-h8a8886c_1 \r\n glib: 2.56.2-hd408876_0 \r\n gst-plugins-base: 1.14.0-hbbd80ab_1 \r\n gstreamer: 1.14.0-hb453b48_1 \r\n icu: 58.2-h9c2bf20_1 \r\n intel-openmp: 2019.0-118 \r\n jpeg: 9b-h024ee3a_2 \r\n kiwisolver: 1.0.1-py37hf484d3e_0 \r\n libedit: 3.1.20170329-h6b74fdf_2\r\n libffi: 3.2.1-hd88cf55_4 \r\n libgcc-ng: 8.2.0-hdf63c60_1 \r\n libgfortran-ng: 7.3.0-hdf63c60_0 \r\n libpng: 1.6.35-hbc83047_0 \r\n libstdcxx-ng: 8.2.0-hdf63c60_1 \r\n libuuid: 1.0.3-h1bed415_2 \r\n libxcb: 1.13-h1bed415_1 \r\n libxml2: 2.9.8-h26e45fe_1 \r\n matplotlib: 3.0.1-py37h5429711_0 \r\n mkl: 2019.0-118 \r\n mkl_fft: 1.0.6-py37h7dd41cf_0 \r\n mkl_random: 1.0.1-py37h4414c95_1 \r\n ncurses: 6.1-hf484d3e_0 \r\n numpy: 1.15.3-py37h1d66e8a_0 \r\n numpy-base: 1.15.3-py37h81de0dd_0 \r\n openssl: 1.0.2p-h14c3975_0 \r\n pcre: 8.42-h439df22_0 \r\n pip: 10.0.1-py37_0 \r\n pyparsing: 2.2.2-py37_0 \r\n pyqt: 5.9.2-py37h05f1152_2 \r\n python: 3.7.0-h6e4f718_3 \r\n python-dateutil: 2.7.3-py37_0 \r\n pytz: 2018.5-py37_0 \r\n qt: 5.9.6-h8703b6f_2 \r\n readline: 7.0-h7b6447c_5 \r\n setuptools: 40.4.3-py37_0 \r\n sip: 4.19.8-py37hf484d3e_0 \r\n six: 1.11.0-py37_1 \r\n sqlite: 3.25.2-h7b6447c_0 \r\n tk: 8.6.8-hbc83047_0 \r\n tornado: 5.1.1-py37h7b6447c_0 \r\n wheel: 0.32.2-py37_0 \r\n xz: 5.2.4-h14c3975_4 \r\n zlib: 1.2.11-ha838bed_2 \r\n\r\n\r\nDownloading and Extracting Packages\r\nmatplotlib-3.0.1 | 6.6 MB | ########################################################################### | 100% \r\nPreparing transaction: done\r\nVerifying transaction: done\r\nExecuting transaction: done\r\n#\r\n# To activate this environment, use\r\n#\r\n# $ conda activate /tmp/mpl3\r\n#\r\n# To deactivate an active environment, use\r\n#\r\n# $ conda deactivate\r\n\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n\u003cdetails\u003e\r\n\u003csummary\u003eMatplotlib 2 conda environment\u003c/summary\u003e\r\n\r\n```\r\n$ conda create -p /tmp/mpl2 matplotlib=2 --yes (/tmp/mpl3) \r\nSolving environment: done\r\n\r\n## Package Plan ##\r\n\r\n environment location: /tmp/mpl2\r\n\r\n added / updated specs: \r\n - matplotlib=2\r\n\r\n\r\nThe following NEW packages will be INSTALLED:\r\n\r\n blas: 1.0-mkl \r\n ca-certificates: 2018.03.07-0 \r\n certifi: 2018.10.15-py37_0 \r\n cycler: 0.10.0-py37_0 \r\n dbus: 1.13.2-h714fa37_1 \r\n expat: 2.2.6-he6710b0_0 \r\n fontconfig: 2.13.0-h9420a91_0 \r\n freetype: 2.9.1-h8a8886c_1 \r\n glib: 2.56.2-hd408876_0 \r\n gst-plugins-base: 1.14.0-hbbd80ab_1 \r\n gstreamer: 1.14.0-hb453b48_1 \r\n icu: 58.2-h9c2bf20_1 \r\n intel-openmp: 2019.0-118 \r\n jpeg: 9b-h024ee3a_2 \r\n kiwisolver: 1.0.1-py37hf484d3e_0 \r\n libedit: 3.1.20170329-h6b74fdf_2\r\n libffi: 3.2.1-hd88cf55_4 \r\n libgcc-ng: 8.2.0-hdf63c60_1 \r\n libgfortran-ng: 7.3.0-hdf63c60_0 \r\n libpng: 1.6.35-hbc83047_0 \r\n libstdcxx-ng: 8.2.0-hdf63c60_1 \r\n libuuid: 1.0.3-h1bed415_2 \r\n libxcb: 1.13-h1bed415_1 \r\n libxml2: 2.9.8-h26e45fe_1 \r\n matplotlib: 2.2.3-py37hb69df0a_0 \r\n mkl: 2019.0-118 \r\n mkl_fft: 1.0.6-py37h7dd41cf_0 \r\n mkl_random: 1.0.1-py37h4414c95_1 \r\n ncurses: 6.1-hf484d3e_0 \r\n numpy: 1.15.3-py37h1d66e8a_0 \r\n numpy-base: 1.15.3-py37h81de0dd_0 \r\n openssl: 1.0.2p-h14c3975_0 \r\n pcre: 8.42-h439df22_0 \r\n pip: 10.0.1-py37_0 \r\n pyparsing: 2.2.2-py37_0 \r\n pyqt: 5.9.2-py37h05f1152_2 \r\n python: 3.7.0-h6e4f718_3 \r\n python-dateutil: 2.7.3-py37_0 \r\n pytz: 2018.5-py37_0 \r\n qt: 5.9.6-h8703b6f_2 \r\n readline: 7.0-h7b6447c_5 \r\n setuptools: 40.4.3-py37_0 \r\n sip: 4.19.8-py37hf484d3e_0 \r\n six: 1.11.0-py37_1 \r\n sqlite: 3.25.2-h7b6447c_0 \r\n tk: 8.6.8-hbc83047_0 \r\n tornado: 5.1.1-py37h7b6447c_0 \r\n wheel: 0.32.2-py37_0 \r\n xz: 5.2.4-h14c3975_4 \r\n zlib: 1.2.11-ha838bed_2 \r\n\r\nPreparing transaction: done\r\nVerifying transaction: done\r\nExecuting transaction: done\r\n#\r\n# To activate this environment, use\r\n#\r\n# $ conda activate /tmp/mpl2\r\n#\r\n# To deactivate an active environment, use\r\n#\r\n# $ conda deactivate\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\nThe issue has been encountered in real code that expects MPL to deal with nan\r\nvalues properly.\r\n","author":{"url":"https://github.com/Zaharid","@type":"Person","name":"Zaharid"},"datePublished":"2018-10-27T10:44:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/12648/matplotlib/issues/12648"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:30d270f9-8011-9d39-4bd5-355736ad2565 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DA60:240794:2D064B3:3CCBE93:6A53BA17 |
| html-safe-nonce | 2cc6ea60b77e715d0ca1ff0bf1a3532a86211ec7374d360199d29ef87b03dd0c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTYwOjI0MDc5NDoyRDA2NEIzOjNDQ0JFOTM6NkE1M0JBMTciLCJ2aXNpdG9yX2lkIjoiNDQ4MzkwOTc1NTMxMjc4MTg0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f04c94957d738075b76af460f80e728b2f2fb71b62a4999cb490751883511217 |
| hovercard-subject-tag | issue:374632032 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/12648/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4a098ce2b9bc4d807381c070762d9514497022d2c1f86f390bef576587e5ecb3/matplotlib/matplotlib/issues/12648 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4a098ce2b9bc4d807381c070762d9514497022d2c1f86f390bef576587e5ecb3/matplotlib/matplotlib/issues/12648 |
| og:image:alt | The following code: import matplotlib.pyplot as plt plt.annotate('X', (0, float('nan'))) plt.tight_layout() plt.savefig('crash.png') raises an exception when using matplotlib 3, including 3.0.1. It... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Zaharid |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width