Title: Rendering issue occurs when plotting 3D surfaces at a discontinuity · Issue #12395 · matplotlib/matplotlib · GitHub
Open Graph Title: Rendering issue occurs when plotting 3D surfaces at a discontinuity · Issue #12395 · matplotlib/matplotlib
X Title: Rendering issue occurs when plotting 3D surfaces at a discontinuity · Issue #12395 · matplotlib/matplotlib
Description: Bug report Bug summary When running the code below to plot the surface for the equation 1 - y/x, the plot works but I get an error and the rendering of the surface breaks when viewed from some angles. Code for reproduction import math im...
Open Graph Description: Bug report Bug summary When running the code below to plot the surface for the equation 1 - y/x, the plot works but I get an error and the rendering of the surface breaks when viewed from some angl...
X Description: Bug report Bug summary When running the code below to plot the surface for the equation 1 - y/x, the plot works but I get an error and the rendering of the surface breaks when viewed from some angl...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/12395
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Rendering issue occurs when plotting 3D surfaces at a discontinuity","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\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\nWhen running the code below to plot the surface for the equation 1 - y/x, the plot works but I get an error and the rendering of the surface breaks when viewed from some angles.\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\nimport math\r\nimport numpy as np\r\nimport matplotlib as mpl\r\nimport matplotlib.pyplot as plt\r\nimport matplotlib.ticker\r\nfrom matplotlib import cm\r\nfrom mpl_toolkits.mplot3d import Axes3D\r\n\r\n# Generate the data\r\nx = np.linspace(-1.0, 1.0, 50)\r\ny = np.linspace(-1.0, 1.0, 50)\r\nz = np.zeros(len(x))\r\nx,y = np.meshgrid(x,y)\r\nz = 1 - y/x\r\nz[z \u003e= 5.0] = 5.0 # Clips top of surface\r\nz[z \u003c= -5.0] = -5.0 # Clips bottom of surface\r\n\r\n# place NaNs at the discontinuity\r\npos = np.where(np.abs(np.diff(z)) \u003e= 5.0)\r\nz[pos] = np.nan\r\n\r\n# Create the plot\r\np1 = plt.figure()\r\nax = p1.gca(projection='3d')\r\nsurf = ax.plot_surface(x,y,z, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0,\r\n vmin=np.nanmin(z), vmax=np.nanmax(z), antialiased=False)\r\nplt.title(\"1 - y/x\")\r\nax.set_xlim(-1.0, 1.0)\r\nax.set_ylim(-1.0, 1.0)\r\nax.set_zlim(-5.0, 5.0)\r\nax.set_xlabel(\"x\")\r\nax.set_ylabel(\"y\")\r\nax.set_zlabel(\"z\")\r\np1.show()\r\nraw_input(\"Press any key to close all plots: \")\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\n/usr/lib/pymodules/python2.7/matplotlib/colors.py:576: RuntimeWarning: invalid value encountered in less\r\n cbook._putmask(xa, xa \u003c 0.0, -1)\r\n```\r\n\r\nOdd rendering issues appear:\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n**Expected outcome**\r\n\r\n\u003c!--A description of the expected outcome from the code snippet--\u003e\r\n\u003c!--If this used to work in an earlier version of Matplotlib, please note the version it used to work on--\u003e\r\n\r\nI'd expect to not get errors and to not see the rendering issue. I am using older versions of virtually everything, and this may be a platform-specific issue. Or I may be using this code in a way it was not intended to be used, in which case if there is a more-correct way to do this I'd appreciate someone showing me how to do it.\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: Ubuntu 14.04\r\n * Matplotlib version: 1.3.1\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): 'TkAgg'\r\n * Python version: 2.7.6\r\n * Jupyter version (if applicable): N/A\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/mattforestyoung","@type":"Person","name":"mattforestyoung"},"datePublished":"2018-10-04T00:15:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/12395/matplotlib/issues/12395"}
| 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:99765007-e47c-478b-93a4-092422cc3ad1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A392:2A854D:1CAAD45:2980C9B:6A54F6D0 |
| html-safe-nonce | a34fa5393f52292344d9bcf9f7c24b8f84c9d9e9115951980f8e6c8438ad0a58 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzkyOjJBODU0RDoxQ0FBRDQ1OjI5ODBDOUI6NkE1NEY2RDAiLCJ2aXNpdG9yX2lkIjoiODQ4OTA0MzU3ODYxNzkxOTE4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 55e3e8516a22af9b7cf52655a5bd4c07b464dc97da293debaf81b25d5623b2d9 |
| hovercard-subject-tag | issue:366576496 |
| 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/12395/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d4ca57647deaca0e236ec65188e3314141f8c59a39d76d318ca2a53d30fd5656/matplotlib/matplotlib/issues/12395 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d4ca57647deaca0e236ec65188e3314141f8c59a39d76d318ca2a53d30fd5656/matplotlib/matplotlib/issues/12395 |
| og:image:alt | Bug report Bug summary When running the code below to plot the surface for the equation 1 - y/x, the plot works but I get an error and the rendering of the surface breaks when viewed from some angl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mattforestyoung |
| hostname | github.com |
| expected-hostname | github.com |
| None | eae2aab99907699a22d2c8449aa683ca74454fca87211b98f7c7b722086b2839 |
| 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 | dd26d3896747463b6bd56edd5e290edb595c3cbc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width