Title: pyplot.savefig fails with ValueError: cannot convert float NaN to integer · Issue #4318 · matplotlib/matplotlib · GitHub
Open Graph Title: pyplot.savefig fails with ValueError: cannot convert float NaN to integer · Issue #4318 · matplotlib/matplotlib
X Title: pyplot.savefig fails with ValueError: cannot convert float NaN to integer · Issue #4318 · matplotlib/matplotlib
Description: I think this is happening because I am plotting a gaussian that is very narrow compared to the x range. Still it seems failing here is bad behavior. here is some code that reproduces the problem, taken from IPython notebook: %matplotlib ...
Open Graph Description: I think this is happening because I am plotting a gaussian that is very narrow compared to the x range. Still it seems failing here is bad behavior. here is some code that reproduces the problem, t...
X Description: I think this is happening because I am plotting a gaussian that is very narrow compared to the x range. Still it seems failing here is bad behavior. here is some code that reproduces the problem, t...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/4318
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"pyplot.savefig fails with ValueError: cannot convert float NaN to integer","articleBody":"I think this is happening because I am plotting a gaussian that is very narrow compared to the x range. Still it seems failing here is bad behavior.\n\nhere is some code that reproduces the problem, taken from IPython notebook:\n\n``` python\n %matplotlib inline\n import matplotlib.pyplot as plt\n from scipy.stats import norm as scipy_stats_norm\n from math import sqrt\n\n plt.clf()\n fig, ax = plt.subplots()\n\n max_x = 1100 # this fails\n #max_x = 1000 # this works\n x = np.linspace(-max_x, max_x, 300) \n\n mean = -0.0938\n stdev = sqrt(0.008812)\n ax.plot(x, scipy_stats_norm.pdf(x, loc=mean, scale=stdev), color='red', linewidth=2)\n\n ax.set_yticklabels([])\n ax.set_xlim(-max_x, max_x)\n\n filename = '/tmp/fail.png'\n plt.savefig(filename, bbox_inches='tight')\n plt.show()\n```\n\nHere's the result:\n\n``` python\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/pyplot.py\", line 561, in savefig\n return fig.savefig(*args, **kwargs)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/figure.py\", line 1421, in savefig\n self.canvas.print_figure(*args, **kwargs)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/backend_bases.py\", line 2167, in print_figure\n **kwargs)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py\", line 505, in print_png\n FigureCanvasAgg.draw(self)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py\", line 451, in draw\n self.figure.draw(self.renderer)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/artist.py\", line 55, in draw_wrapper\n draw(artist, renderer, *args, **kwargs)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/figure.py\", line 1034, in draw\n func(*args)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/artist.py\", line 55, in draw_wrapper\n draw(artist, renderer, *args, **kwargs)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/axes.py\", line 2086, in draw\n a.draw(renderer)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/artist.py\", line 55, in draw_wrapper\n draw(artist, renderer, *args, **kwargs)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/axis.py\", line 1096, in draw\n tick.draw(renderer)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/artist.py\", line 55, in draw_wrapper\n draw(artist, renderer, *args, **kwargs)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/axis.py\", line 241, in draw\n self.label1.draw(renderer)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/artist.py\", line 55, in draw_wrapper\n draw(artist, renderer, *args, **kwargs)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/text.py\", line 598, in draw\n ismath=ismath, mtext=self)\n File \"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py\", line 188, in draw_text\n font.get_image(), np.round(x - xd), np.round(y + yd) + 1, angle, gc)\nValueError: cannot convert float NaN to integer\n```\n","author":{"url":"https://github.com/jessehersch","@type":"Person","name":"jessehersch"},"datePublished":"2015-04-07T23:49:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":32},"url":"https://github.com/4318/matplotlib/issues/4318"}
| 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:7cf5a25a-21ed-52b9-afaf-e725efec0806 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C604:2F9C11:8AAC5C:B8E378:6A5421E7 |
| html-safe-nonce | e6a8de4d43c7900584b9f45ba363698f6c39bf96eb07a840409deeaf6c1126fc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjA0OjJGOUMxMTo4QUFDNUM6QjhFMzc4OjZBNTQyMUU3IiwidmlzaXRvcl9pZCI6IjUwNzQyMzU1NTExMDU5NTAxODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3f4acb6ac0ff3ded2819f45015c733095298f8f012ffd56450005e4fb05b63cf |
| hovercard-subject-tag | issue:67015467 |
| 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/4318/issue_layout |
| twitter:image | https://opengraph.githubassets.com/80e371d0372d07665e5de9c9bd87bfbc5526944f8ce3726fd8affa5b1eaabb63/matplotlib/matplotlib/issues/4318 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/80e371d0372d07665e5de9c9bd87bfbc5526944f8ce3726fd8affa5b1eaabb63/matplotlib/matplotlib/issues/4318 |
| og:image:alt | I think this is happening because I am plotting a gaussian that is very narrow compared to the x range. Still it seems failing here is bad behavior. here is some code that reproduces the problem, t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jessehersch |
| 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