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
The following code:
importmatplotlib.pyplotaspltplt.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/lib/python3.7/site-packages/numpy/core/fromnumeric.py:83: RuntimeWarning: invalid value encountered in reduce return ufunc.reduce(obj, axis, dtype, out, **passkwargs)/tmp/mpl3/lib/python3.7/site-packages/numpy/core/_methods.py:32: RuntimeWarning: invalid value encountered in reduce return umr_minimum(a, axis, None, out, keepdims, initial)/tmp/mpl3/lib/python3.7/site-packages/numpy/core/_methods.py:28: RuntimeWarning: invalid value encountered in reduce return umr_maximum(a, axis, None, out, keepdims, initial)Traceback (most recent call last): File"mplbug.py", line5, in<module> plt.savefig('crash.png') File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/pyplot.py", line689, insavefig res= fig.savefig(*args,**kwargs) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/figure.py", line2094, insavefigself.canvas.print_figure(fname,**kwargs) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/backends/backend_qt5agg.py", line88, inprint_figuresuper().print_figure(*args,**kwargs) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/backend_bases.py", line2075, inprint_figure**kwargs) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/backends/backend_agg.py", line510, inprint_png FigureCanvasAgg.draw(self) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/backends/backend_agg.py", line402, indrawself.figure.draw(self.renderer) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/artist.py", line50, indraw_wrapperreturn draw(artist, renderer,*args,**kwargs) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/figure.py", line1649, indraw renderer,self, artists,self.suppressComposite) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/image.py", line138, in_draw_list_compositing_images a.draw(renderer) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/artist.py", line50, indraw_wrapperreturn draw(artist, renderer,*args,**kwargs) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/axes/_base.py", line2610, indraw mimage._draw_list_compositing_images(renderer,self, artists) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/image.py", line138, in_draw_list_compositing_images a.draw(renderer) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/artist.py", line50, indraw_wrapperreturn draw(artist, renderer,*args,**kwargs) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/axis.py", line1185, indraw ticks_to_draw=self._update_ticks(renderer) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/axis.py", line1023, in_update_ticks tick_tups=list(self.iter_ticks())# iter_ticks calls the locator File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/axis.py", line967, initer_ticks majorLocs=self.major.locator() File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/ticker.py", line1985, in__call__returnself.tick_values(vmin, vmax) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/ticker.py", line1993, intick_values locs=self._raw_ticks(vmin, vmax) File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/ticker.py", line1932, in_raw_ticks nbins= np.clip(self.axis.get_tick_space(), File"/tmp/mpl3/lib/python3.7/site-packages/matplotlib/axis.py", line2159, inget_tick_spacereturnint(np.floor(length/ size))ValueError:cannot convert float NaN to integer
Based on the traceback, the following issues might be related:
#10360 (likely this is a duplicate)
#11386
#6789
The snippet has been tested on brand new conda environments with the defaults
channel.
Matplotlib 3 env
$ conda create -p /tmp/mpl3 matplotlib=3 --yesSolving environment: done## Package Plan ## environment location: /tmp/mpl3 added / updated specs: - matplotlib=3The following packages will be downloaded: package | build ---------------------------|----------------- matplotlib-3.0.1 | py37h5429711_0 6.6 MBThe following NEW packages will be INSTALLED: blas: 1.0-mkl ca-certificates: 2018.03.07-0 certifi: 2018.10.15-py37_0 cycler: 0.10.0-py37_0 dbus: 1.13.2-h714fa37_1 expat: 2.2.6-he6710b0_0 fontconfig: 2.13.0-h9420a91_0 freetype: 2.9.1-h8a8886c_1 glib: 2.56.2-hd408876_0 gst-plugins-base: 1.14.0-hbbd80ab_1 gstreamer: 1.14.0-hb453b48_1 icu: 58.2-h9c2bf20_1 intel-openmp: 2019.0-118 jpeg: 9b-h024ee3a_2 kiwisolver: 1.0.1-py37hf484d3e_0 libedit: 3.1.20170329-h6b74fdf_2 libffi: 3.2.1-hd88cf55_4 libgcc-ng: 8.2.0-hdf63c60_1 libgfortran-ng: 7.3.0-hdf63c60_0 libpng: 1.6.35-hbc83047_0 libstdcxx-ng: 8.2.0-hdf63c60_1 libuuid: 1.0.3-h1bed415_2 libxcb: 1.13-h1bed415_1 libxml2: 2.9.8-h26e45fe_1 matplotlib: 3.0.1-py37h5429711_0 mkl: 2019.0-118 mkl_fft: 1.0.6-py37h7dd41cf_0 mkl_random: 1.0.1-py37h4414c95_1 ncurses: 6.1-hf484d3e_0 numpy: 1.15.3-py37h1d66e8a_0 numpy-base: 1.15.3-py37h81de0dd_0 openssl: 1.0.2p-h14c3975_0 pcre: 8.42-h439df22_0 pip: 10.0.1-py37_0 pyparsing: 2.2.2-py37_0 pyqt: 5.9.2-py37h05f1152_2 python: 3.7.0-h6e4f718_3 python-dateutil: 2.7.3-py37_0 pytz: 2018.5-py37_0 qt: 5.9.6-h8703b6f_2 readline: 7.0-h7b6447c_5 setuptools: 40.4.3-py37_0 sip: 4.19.8-py37hf484d3e_0 six: 1.11.0-py37_1 sqlite: 3.25.2-h7b6447c_0 tk: 8.6.8-hbc83047_0 tornado: 5.1.1-py37h7b6447c_0 wheel: 0.32.2-py37_0 xz: 5.2.4-h14c3975_4 zlib: 1.2.11-ha838bed_2 Downloading and Extracting Packagesmatplotlib-3.0.1 | 6.6 MB | ########################################################################### | 100% Preparing transaction: doneVerifying transaction: doneExecuting transaction: done## To activate this environment, use## $ conda activate /tmp/mpl3## To deactivate an active environment, use## $ conda deactivate
Matplotlib 2 conda environment
$ conda create -p /tmp/mpl2 matplotlib=2 --yes (/tmp/mpl3) Solving environment: done## Package Plan ## environment location: /tmp/mpl2 added / updated specs: - matplotlib=2The following NEW packages will be INSTALLED: blas: 1.0-mkl ca-certificates: 2018.03.07-0 certifi: 2018.10.15-py37_0 cycler: 0.10.0-py37_0 dbus: 1.13.2-h714fa37_1 expat: 2.2.6-he6710b0_0 fontconfig: 2.13.0-h9420a91_0 freetype: 2.9.1-h8a8886c_1 glib: 2.56.2-hd408876_0 gst-plugins-base: 1.14.0-hbbd80ab_1 gstreamer: 1.14.0-hb453b48_1 icu: 58.2-h9c2bf20_1 intel-openmp: 2019.0-118 jpeg: 9b-h024ee3a_2 kiwisolver: 1.0.1-py37hf484d3e_0 libedit: 3.1.20170329-h6b74fdf_2 libffi: 3.2.1-hd88cf55_4 libgcc-ng: 8.2.0-hdf63c60_1 libgfortran-ng: 7.3.0-hdf63c60_0 libpng: 1.6.35-hbc83047_0 libstdcxx-ng: 8.2.0-hdf63c60_1 libuuid: 1.0.3-h1bed415_2 libxcb: 1.13-h1bed415_1 libxml2: 2.9.8-h26e45fe_1 matplotlib: 2.2.3-py37hb69df0a_0 mkl: 2019.0-118 mkl_fft: 1.0.6-py37h7dd41cf_0 mkl_random: 1.0.1-py37h4414c95_1 ncurses: 6.1-hf484d3e_0 numpy: 1.15.3-py37h1d66e8a_0 numpy-base: 1.15.3-py37h81de0dd_0 openssl: 1.0.2p-h14c3975_0 pcre: 8.42-h439df22_0 pip: 10.0.1-py37_0 pyparsing: 2.2.2-py37_0 pyqt: 5.9.2-py37h05f1152_2 python: 3.7.0-h6e4f718_3 python-dateutil: 2.7.3-py37_0 pytz: 2018.5-py37_0 qt: 5.9.6-h8703b6f_2 readline: 7.0-h7b6447c_5 setuptools: 40.4.3-py37_0 sip: 4.19.8-py37hf484d3e_0 six: 1.11.0-py37_1 sqlite: 3.25.2-h7b6447c_0 tk: 8.6.8-hbc83047_0 tornado: 5.1.1-py37h7b6447c_0 wheel: 0.32.2-py37_0 xz: 5.2.4-h14c3975_4 zlib: 1.2.11-ha838bed_2 Preparing transaction: doneVerifying transaction: doneExecuting transaction: done## To activate this environment, use## $ conda activate /tmp/mpl2## To deactivate an active environment, use## $ conda deactivate
The issue has been encountered in real code that expects MPL to deal with nan
values properly.
Metadata
Metadata
Assignees
Labels
No labels