René's URL Explorer Experiment


Title: ValueError: cannot convert float NaN to integer · Issue #15093 · matplotlib/matplotlib · GitHub

Open Graph Title: ValueError: cannot convert float NaN to integer · Issue #15093 · matplotlib/matplotlib

X Title: ValueError: cannot convert float NaN to integer · Issue #15093 · matplotlib/matplotlib

Description: Bug report Bug summary Code for reproduction import matplotlib import matplotlib.pyplot as plt import numpy as np plt.rcParams['figure.figsize'] = 10,10 class MidpointNormalize(matplotlib.colors.Normalize): def __init__(self, vmin=None, ...

Open Graph Description: Bug report Bug summary Code for reproduction import matplotlib import matplotlib.pyplot as plt import numpy as np plt.rcParams['figure.figsize'] = 10,10 class MidpointNormalize(matplotlib.colors.No...

X Description: Bug report Bug summary Code for reproduction import matplotlib import matplotlib.pyplot as plt import numpy as np plt.rcParams['figure.figsize'] = 10,10 class MidpointNormalize(matplotlib.c...

Opengraph URL: https://github.com/matplotlib/matplotlib/issues/15093

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ValueError: cannot convert float NaN to integer","articleBody":"### 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```python\r\nimport matplotlib\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\nplt.rcParams['figure.figsize'] = 10,10\r\n\r\nclass MidpointNormalize(matplotlib.colors.Normalize):\r\n    def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):\r\n        self.midpoint = midpoint\r\n        matplotlib.colors.Normalize.__init__(self, vmin, vmax, clip)\r\n\r\n    def __call__(self, value, clip=None):\r\n        # Note that I'm ignoring clipping and other edge cases here.\r\n        result, is_scalar = self.process_value(value)\r\n        x, y = [self.vmin, self.midpoint, self.vmax], [0, 0.5, 1]\r\n        return np.ma.array(np.interp(value, x, y), mask=result.mask, copy=False)\r\n\r\n# make these smaller to increase the resolution\r\ndx, dy = 0.15, 0.05\r\n\r\n# generate 2 2d grids for the x \u0026 y bounds\r\ny, x = np.mgrid[slice(-3, 3 + dy, dy),\r\n                slice(-3, 3 + dx, dx)]\r\nz = (1 - x / 2. + x ** 5 + y ** 3) * np.exp(-x ** 2 - y ** 2)\r\n\r\nz = z[:-1, :-1]\r\nz_min, z_max = -np.abs(z).max(), np.abs(z).max()\r\nz [0:2,0:2] = np.nan\r\n\r\nplt.pcolormesh(x, y, z, cmap='seismic',norm=MidpointNormalize(midpoint=0.,vmin=-3,vmax=3))\r\nplt.title('pcolormesh')\r\nplt.axis([x.min(), x.max(), y.min(), y.max()])\r\nplt.colorbar(extend='min')\r\n\r\nplt.tight_layout(w_pad=0.1, h_pad=1)\r\nplt.savefig('test.png', dpi = 720)\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\nE:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\colorbar.py:1042: RuntimeWarning: invalid value encountered in true_divide\r\n  z = np.take(y, i0) + (xn - np.take(b, i0)) * dy / db\r\nE:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\transforms.py:402: RuntimeWarning: invalid value encountered in double_scalars\r\n  return points[1, 0] - points[0, 0]\r\nTraceback (most recent call last):\r\n  File \"C:\\Users\\Xin\\Desktop\\test_extend.py\", line 37, in \u003cmodule\u003e\r\n    plt.savefig('test.png', dpi = 720)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\pyplot.py\", line 689, in savefig\r\n    res = fig.savefig(*args, **kwargs)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\figure.py\", line 2094, in savefig\r\n    self.canvas.print_figure(fname, **kwargs)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\backend_bases.py\", line 2075, in print_figure\r\n    **kwargs)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\backends\\backend_agg.py\", line 510, in print_png\r\n    FigureCanvasAgg.draw(self)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\backends\\backend_agg.py\", line 402, in draw\r\n    self.figure.draw(self.renderer)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\artist.py\", line 50, in draw_wrapper\r\n    return draw(artist, renderer, *args, **kwargs)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\figure.py\", line 1649, in draw\r\n    renderer, self, artists, self.suppressComposite)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\image.py\", line 138, in _draw_list_compositing_images\r\n    a.draw(renderer)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\artist.py\", line 50, in draw_wrapper\r\n    return draw(artist, renderer, *args, **kwargs)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\axes\\_base.py\", line 2628, in draw\r\n    mimage._draw_list_compositing_images(renderer, self, artists)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\image.py\", line 138, in _draw_list_compositing_images\r\n    a.draw(renderer)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\artist.py\", line 50, in draw_wrapper\r\n    return draw(artist, renderer, *args, **kwargs)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\axis.py\", line 1185, in draw\r\n    ticks_to_draw = self._update_ticks(renderer)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\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 \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\axis.py\", line 967, in iter_ticks\r\n    majorLocs = self.major.locator()\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\ticker.py\", line 1985, in __call__\r\n    return self.tick_values(vmin, vmax)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\ticker.py\", line 1993, in tick_values\r\n    locs = self._raw_ticks(vmin, vmax)\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\site-packages\\matplotlib\\ticker.py\", line 1932, in _raw_ticks\r\n    nbins = np.clip(self.axis.get_tick_space(),\r\n  File \"E:\\miniconda3\\envs\\satpy\\lib\\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**Expected outcome**\r\n\r\n![image](https://user-images.githubusercontent.com/30388627/63422517-1243e780-c43d-11e9-8577-095ff914b576.png)\r\n\r\n**Tmp solution**\r\nAdd the min and max of z to `vmin` and `vmax`:\r\n```\r\nplt.pcolormesh(x, y, z, vmin=z_min, vmax=z_max, cmap='seismic',norm=MidpointNormalize(midpoint=0.,vmin=-3,vmax=3))\r\n```\r\n\r\nHowever, it doesn't work if the vmin or vmax is beyond that:\r\n```\r\nplt.pcolormesh(x, y, z, vmin=-2, vmax=z_max, cmap='seismic',norm=MidpointNormalize(midpoint=0.,vmin=-3,vmax=3))\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: Win 10\r\n  * Matplotlib version: 3.0.3 (conda-forge)\r\n  * Matplotlib backend: TkAgg\r\n  * Python version: 3.6.7","author":{"url":"https://github.com/zxdawn","@type":"Person","name":"zxdawn"},"datePublished":"2019-08-21T10:01:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/15093/matplotlib/issues/15093"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b81e4812-dabe-d072-2207-aa59d592d314
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id90BE:2D0EDC:91F283:D3D05D:6A549BE8
html-safe-nonce816d35b780df6076eacec5980c03a302c5482629640d48f0abbbc26ff0ab5787
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MEJFOjJEMEVEQzo5MUYyODM6RDNEMDVEOjZBNTQ5QkU4IiwidmlzaXRvcl9pZCI6IjI2MjI4MDkzNDY4Nzk1NjA2ODAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac04ae10c15854ef7c0023ac03894ae07244cfc157374e383515704f2d2f8d228f
hovercard-subject-tagissue:483324166
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/15093/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9572b3073f01503477040e84229eedc59c1a5d8ddbfe9d447beae0e084bddfbb/matplotlib/matplotlib/issues/15093
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9572b3073f01503477040e84229eedc59c1a5d8ddbfe9d447beae0e084bddfbb/matplotlib/matplotlib/issues/15093
og:image:altBug report Bug summary Code for reproduction import matplotlib import matplotlib.pyplot as plt import numpy as np plt.rcParams['figure.figsize'] = 10,10 class MidpointNormalize(matplotlib.colors.No...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamezxdawn
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
turbo-cache-controlno-preview
go-importgithub.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git
octolytics-dimension-user_id215947
octolytics-dimension-user_loginmatplotlib
octolytics-dimension-repository_id1385122
octolytics-dimension-repository_nwomatplotlib/matplotlib
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1385122
octolytics-dimension-repository_network_root_nwomatplotlib/matplotlib
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef8cfff6384f62259baea531c7f58bc7040f8dd92
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/issues/15093#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F15093
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F15093
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/issues/15093
Reloadhttps://github.com/matplotlib/matplotlib/issues/15093
Reloadhttps://github.com/matplotlib/matplotlib/issues/15093
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/15093
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/15093
Notifications https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Fork 8.4k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Star 23k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Code https://github.com/matplotlib/matplotlib
Issues 1.1k https://github.com/matplotlib/matplotlib/issues
Pull requests 408 https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality 0 https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
Code https://github.com/matplotlib/matplotlib
Issues https://github.com/matplotlib/matplotlib/issues
Pull requests https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
ValueError: cannot convert float NaN to integerhttps://github.com/matplotlib/matplotlib/issues/15093#top
https://github.com/zxdawn
zxdawnhttps://github.com/zxdawn
on Aug 21, 2019https://github.com/matplotlib/matplotlib/issues/15093#issue-483324166
https://user-images.githubusercontent.com/30388627/63422517-1243e780-c43d-11e9-8577-095ff914b576.png
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.