Title: Axes.pie([0, 0]) crashes with “cannot convert float NaN to integer” when all slice sizes are zero · Issue #30007 · matplotlib/matplotlib · GitHub
Open Graph Title: Axes.pie([0, 0]) crashes with “cannot convert float NaN to integer” when all slice sizes are zero · Issue #30007 · matplotlib/matplotlib
X Title: Axes.pie([0, 0]) crashes with “cannot convert float NaN to integer” when all slice sizes are zero · Issue #30007 · matplotlib/matplotlib
Description: Calling ax.pie() with all-zero data leads to an internal NaN→int conversion failure, rather than a clean “all zero input” error or an empty plot. Reproducible example import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as pl...
Open Graph Description: Calling ax.pie() with all-zero data leads to an internal NaN→int conversion failure, rather than a clean “all zero input” error or an empty plot. Reproducible example import matplotlib matplotlib.u...
X Description: Calling ax.pie() with all-zero data leads to an internal NaN→int conversion failure, rather than a clean “all zero input” error or an empty plot. Reproducible example import matplotlib matplotlib.u...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30007
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Axes.pie([0, 0]) crashes with “cannot convert float NaN to integer” when all slice sizes are zero","articleBody":"Calling ax.pie() with all-zero data leads to an internal NaN→int conversion failure, rather than a clean “all zero input” error or an empty plot.\n\n\nReproducible example\n\n```\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nfig, ax = plt.subplots()\nax.pie([0, 0], labels=[\"A\", \"B\"])\nfig.savefig(\"out.png\")`\n```\n\nTraceback\n\n\n```\nRuntimeWarning: invalid value encountered in divide\n x = x / sx\n...\n File \".../matplotlib/axes/_axes.py\", line 3409, in pie\n w = mpatches.Wedge((x, y), radius, 360. * min(theta1, theta2),\n ...\n File \".../matplotlib/patches.py\", line 1264, in _recompute_path\n arc = Path.arc(theta1, theta2)\n File \".../matplotlib/path.py\", line 961, in arc\n n = int(2 ** np.ceil((eta2 - eta1) / halfpi))\nValueError: cannot convert float NaN to integer\n```\n\n\nExpected behavior\n\nEither:\n\nRender an empty/placeholder pie when slice‐sizes sum to zero\n\nOr raise a clear ValueError(\"All wedge sizes zero\") before entering the NaN conversion","author":{"url":"https://github.com/PouyaSA96","@type":"Person","name":"PouyaSA96"},"datePublished":"2025-05-04T05:39:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/30007/matplotlib/issues/30007"}
| 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:891c5e45-7c76-2029-bff7-62e0e2b84331 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A826:20B327:E602CF:130FBC9:6A519ACC |
| html-safe-nonce | bc10babe47eaf27b24f18fe7e94e49c91ddb9c995ba7c99c841514cadc1d3ae7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODI2OjIwQjMyNzpFNjAyQ0Y6MTMwRkJDOTo2QTUxOUFDQyIsInZpc2l0b3JfaWQiOiI4OTc1MzI0ODM5NjM3MjYxMDA0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b2fc20ec7f0fd20e4366b3f6f2271318770224a76139f63fd4b97ced58525d1f |
| hovercard-subject-tag | issue:3037792841 |
| 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/30007/issue_layout |
| twitter:image | https://opengraph.githubassets.com/42c4a55ad839795a87c6275f7d890d02cd70b384d0aa06bedc35da8cd8ae12d0/matplotlib/matplotlib/issues/30007 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/42c4a55ad839795a87c6275f7d890d02cd70b384d0aa06bedc35da8cd8ae12d0/matplotlib/matplotlib/issues/30007 |
| og:image:alt | Calling ax.pie() with all-zero data leads to an internal NaN→int conversion failure, rather than a clean “all zero input” error or an empty plot. Reproducible example import matplotlib matplotlib.u... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | PouyaSA96 |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width