Title: creating PathCollection proxy artist with %matplotlib inline raises ValueError: cannot convert float NaN to integer · Issue #10360 · matplotlib/matplotlib · GitHub
Open Graph Title: creating PathCollection proxy artist with %matplotlib inline raises ValueError: cannot convert float NaN to integer · Issue #10360 · matplotlib/matplotlib
X Title: creating PathCollection proxy artist with %matplotlib inline raises ValueError: cannot convert float NaN to integer · Issue #10360 · matplotlib/matplotlib
Description: First, I'm not sure if this is a matplotlibor a jupyter bug, so I apologize if I'm posting at the wrong place. I'm having some problems with some code that used to work in a previous version of maptlotlib+jupyter notebook. I managed to t...
Open Graph Description: First, I'm not sure if this is a matplotlibor a jupyter bug, so I apologize if I'm posting at the wrong place. I'm having some problems with some code that used to work in a previous version of map...
X Description: First, I'm not sure if this is a matplotlibor a jupyter bug, so I apologize if I'm posting at the wrong place. I'm having some problems with some code that used to work in a previous ve...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/10360
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"creating PathCollection proxy artist with %matplotlib inline raises ValueError: cannot convert float NaN to integer","articleBody":"First, I'm not sure if this is a `matplotlib`or a `jupyter` bug, so I apologize if I'm posting at the wrong place.\r\n\r\nI'm having some problems with some code that used to work in a previous version of maptlotlib+jupyter notebook.\r\nI managed to trace the problem to creating an empty PathCollection to be used as a legend proxy artist, but the Exception is only raised when using the `inline` backend (`%matplotlib inline`). The code works fine using `%matplotlib notebook` or in ipython using the `MacOSX` backend\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\n\u003c!--A short 1-2 sentences that succinctly describes the bug--\u003e\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug, also minimizing the number of dependencies required--\u003e\r\n\r\n```python\r\n%matplotlib inline\r\nfrom matplotlib import pyplot as plt\r\n_, ax = plt.subplots()\r\na = ax.scatter([], [], clip_on=False,\r\n marker='s', s=20, facecolor='k', \r\n edgecolors='r', linewidths=5, \r\n zorder=100, label='label')\r\nax.legend(handles=[a])\r\n\r\nplt.show()\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\u003c!--The output produced by the above code, which may be a screenshot, console output, etc.--\u003e\r\n\r\n```\r\nValueError Traceback (most recent call last)\r\n~/anaconda3/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)\r\n 339 pass\r\n 340 else:\r\n--\u003e 341 return printer(obj)\r\n 342 # Finally look for special method names\r\n 343 method = get_real_method(obj, self.print_method)\r\n\r\n~/anaconda3/lib/python3.6/site-packages/IPython/core/pylabtools.py in \u003clambda\u003e(fig)\r\n 236 \r\n 237 if 'png' in formats:\r\n--\u003e 238 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))\r\n 239 if 'retina' in formats or 'png2x' in formats:\r\n 240 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))\r\n\r\n~/anaconda3/lib/python3.6/site-packages/IPython/core/pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)\r\n 120 \r\n 121 bytes_io = BytesIO()\r\n--\u003e 122 fig.canvas.print_figure(bytes_io, **kw)\r\n 123 data = bytes_io.getvalue()\r\n 124 if fmt == 'svg':\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)\r\n 2265 orientation=orientation,\r\n 2266 bbox_inches_restore=_bbox_inches_restore,\r\n-\u003e 2267 **kwargs)\r\n 2268 finally:\r\n 2269 if bbox_inches and restore_bbox:\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs)\r\n 505 \r\n 506 def print_png(self, filename_or_obj, *args, **kwargs):\r\n--\u003e 507 FigureCanvasAgg.draw(self)\r\n 508 renderer = self.get_renderer()\r\n 509 original_dpi = renderer.dpi\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in draw(self)\r\n 428 # if toolbar:\r\n 429 # toolbar.set_cursor(cursors.WAIT)\r\n--\u003e 430 self.figure.draw(self.renderer)\r\n 431 finally:\r\n 432 # if toolbar:\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)\r\n 53 renderer.start_filter()\r\n 54 \r\n---\u003e 55 return draw(artist, renderer, *args, **kwargs)\r\n 56 finally:\r\n 57 if artist.get_agg_filter() is not None:\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/figure.py in draw(self, renderer)\r\n 1297 \r\n 1298 mimage._draw_list_compositing_images(\r\n-\u003e 1299 renderer, self, artists, self.suppressComposite)\r\n 1300 \r\n 1301 renderer.close_group('figure')\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)\r\n 136 if not_composite or not has_images:\r\n 137 for a in artists:\r\n--\u003e 138 a.draw(renderer)\r\n 139 else:\r\n 140 # Composite any adjacent images together\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)\r\n 53 renderer.start_filter()\r\n 54 \r\n---\u003e 55 return draw(artist, renderer, *args, **kwargs)\r\n 56 finally:\r\n 57 if artist.get_agg_filter() is not None:\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py in draw(self, renderer, inframe)\r\n 2435 renderer.stop_rasterizing()\r\n 2436 \r\n-\u003e 2437 mimage._draw_list_compositing_images(renderer, self, artists)\r\n 2438 \r\n 2439 renderer.close_group('axes')\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)\r\n 136 if not_composite or not has_images:\r\n 137 for a in artists:\r\n--\u003e 138 a.draw(renderer)\r\n 139 else:\r\n 140 # Composite any adjacent images together\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)\r\n 53 renderer.start_filter()\r\n 54 \r\n---\u003e 55 return draw(artist, renderer, *args, **kwargs)\r\n 56 finally:\r\n 57 if artist.get_agg_filter() is not None:\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/axis.py in draw(self, renderer, *args, **kwargs)\r\n 1131 renderer.open_group(__name__)\r\n 1132 \r\n-\u003e 1133 ticks_to_draw = self._update_ticks(renderer)\r\n 1134 ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,\r\n 1135 renderer)\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/axis.py in _update_ticks(self, renderer)\r\n 972 \r\n 973 interval = self.get_view_interval()\r\n--\u003e 974 tick_tups = list(self.iter_ticks())\r\n 975 if self._smart_bounds and tick_tups:\r\n 976 # handle inverted limits\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/axis.py in iter_ticks(self)\r\n 915 Iterate through all of the major and minor ticks.\r\n 916 \"\"\"\r\n--\u003e 917 majorLocs = self.major.locator()\r\n 918 majorTicks = self.get_major_ticks(len(majorLocs))\r\n 919 self.major.formatter.set_locs(majorLocs)\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/ticker.py in __call__(self)\r\n 1951 def __call__(self):\r\n 1952 vmin, vmax = self.axis.get_view_interval()\r\n-\u003e 1953 return self.tick_values(vmin, vmax)\r\n 1954 \r\n 1955 def tick_values(self, vmin, vmax):\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/ticker.py in tick_values(self, vmin, vmax)\r\n 1959 vmin, vmax = mtransforms.nonsingular(\r\n 1960 vmin, vmax, expander=1e-13, tiny=1e-14)\r\n-\u003e 1961 locs = self._raw_ticks(vmin, vmax)\r\n 1962 \r\n 1963 prune = self._prune\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/ticker.py in _raw_ticks(self, vmin, vmax)\r\n 1901 if self._nbins == 'auto':\r\n 1902 if self.axis is not None:\r\n-\u003e 1903 nbins = np.clip(self.axis.get_tick_space(),\r\n 1904 max(1, self._min_n_ticks - 1), 9)\r\n 1905 else:\r\n\r\n~/anaconda3/lib/python3.6/site-packages/matplotlib/axis.py in get_tick_space(self)\r\n 2060 size = tick.label1.get_size() * 3\r\n 2061 if size \u003e 0:\r\n-\u003e 2062 return int(np.floor(length / size))\r\n 2063 else:\r\n 2064 return 2**31 - 1\r\n\r\nValueError: cannot convert float NaN to integer\r\n```\r\n\r\n**Expected outcome**\r\n\r\nThe exact same code using %matplotlib notebook\r\n```python\r\n%matplotlib notebook\r\nfrom matplotlib import pyplot as plt\r\n_, ax = plt.subplots()\r\na = ax.scatter([], [], clip_on=False,\r\n marker='s', s=20, facecolor='k', \r\n edgecolors='r', linewidths=5, \r\n zorder=100, label='label')\r\nax.legend(handles=[a])\r\n\r\nplt.show()\r\n```\r\nproduces the expected output\r\n\r\n\r\nThe code using %matplotlib inline used to work before, but unfortunately, I don't know which version of matplotlib/jupyter I was using\r\n\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: OSX\r\n * Matplotlib version: 2.1.2\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): module://ipykernel.pylab.backend_inline\r\n * Python version: Python 3.6.4 |Anaconda custom (64-bit)\r\n * Jupyter version (if applicable): `The version of the notebook server is: 5.3.1`\r\n * Other libraries: \r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\n","author":{"url":"https://github.com/DizietAsahi","@type":"Person","name":"DizietAsahi"},"datePublished":"2018-02-01T14:27:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/10360/matplotlib/issues/10360"}
| 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:a4c98a69-2c15-b457-b0b5-29676d3fd795 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D9E0:2D857A:31C14E0:44047BA:6A53EBA8 |
| html-safe-nonce | 61995ab29e4af027c3fb3650d91de1e68746a5ad9b3cf5aa5f4eee7e5078480b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOUUwOjJEODU3QTozMUMxNEUwOjQ0MDQ3QkE6NkE1M0VCQTgiLCJ2aXNpdG9yX2lkIjoiMzkyMTgxNTMzMzYwNzA0MTk2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3af9b0d3fe64c549a9f2a91f7bbabed43ed04fa1154efdea39aa7e5e7f463e02 |
| hovercard-subject-tag | issue:293549855 |
| 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/10360/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bd7ae0ee36238e2b21e02991dc236c4a86216d51b8c08596725d64d5626204ad/matplotlib/matplotlib/issues/10360 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bd7ae0ee36238e2b21e02991dc236c4a86216d51b8c08596725d64d5626204ad/matplotlib/matplotlib/issues/10360 |
| og:image:alt | First, I'm not sure if this is a matplotlibor a jupyter bug, so I apologize if I'm posting at the wrong place. I'm having some problems with some code that used to work in a previous version of map... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DizietAsahi |
| 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