Title: contour and contourf treat levels differently · Issue #10572 · matplotlib/matplotlib · GitHub
Open Graph Title: contour and contourf treat levels differently · Issue #10572 · matplotlib/matplotlib
X Title: contour and contourf treat levels differently · Issue #10572 · matplotlib/matplotlib
Description: Bug report Bug summary When setting levels that span a wider range of values than the data set, contourf correctly picks the right colors to fill the areas between the contour lines. contour does not use the same colors. Code for reprodu...
Open Graph Description: Bug report Bug summary When setting levels that span a wider range of values than the data set, contourf correctly picks the right colors to fill the areas between the contour lines. contour does n...
X Description: Bug report Bug summary When setting levels that span a wider range of values than the data set, contourf correctly picks the right colors to fill the areas between the contour lines. contour does n...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/10572
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"contour and contourf treat levels differently","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\nWhen setting levels that span a wider range of values than the data set, contourf correctly picks the right colors to fill the areas between the contour lines. contour does not use the same colors.\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 numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\nlevels = np.arange(-100, 100, 10)\r\n\r\nx = np.loadtxt(open('x.txt','rb'),delimiter=',')\r\ny = np.loadtxt(open('y.txt','rb'),delimiter=',')\r\nz = np.loadtxt(open('z.txt','rb'),delimiter=',')\r\n\r\n#CS = plt.contour(x, y, z, levels)\r\nCS = plt.contourf(x, y, z, levels)\r\n\r\nCB = plt.colorbar(CS)\r\n\r\nplt.show()\r\n```\r\n\r\nThe data is attached.\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\nWhen plotting with contour instead of contourf the colors range is scaled according to the maximum and minimum of the used data.\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 would expect contour to respect the range set in levels.\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: Debian unstable\r\n * Matplotlib version: 2.1.1-2\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): TkAgg\r\n * Python version: \r\n * Jupyter version (if applicable):\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[z.txt](https://github.com/matplotlib/matplotlib/files/1750666/z.txt)\r\n[y.txt](https://github.com/matplotlib/matplotlib/files/1750667/y.txt)\r\n[x.txt](https://github.com/matplotlib/matplotlib/files/1750668/x.txt)\r\n\r\nInstalled from Debian package","author":{"url":"https://github.com/boeleman","@type":"Person","name":"boeleman"},"datePublished":"2018-02-23T06:37:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/10572/matplotlib/issues/10572"}
| 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:05f9bb65-25c4-c9b8-b82e-2e5db01a5e8a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB64:3D4591:DE6457:1435DB5:6A562A94 |
| html-safe-nonce | 8efa868fc23315ca3bfa9c8a5c8446f418d61aa0fc2e0d25dc8340eb2f8fc6e3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjY0OjNENDU5MTpERTY0NTc6MTQzNURCNTo2QTU2MkE5NCIsInZpc2l0b3JfaWQiOiI1NzY4Nzg3OTE1MjcxNzExMzgwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2a8718ba3013cb2887b3de9cb534849bfd939e8ee8670684823b292bacbaab1c |
| hovercard-subject-tag | issue:299613426 |
| 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/10572/issue_layout |
| twitter:image | https://opengraph.githubassets.com/72ee8ae6ef69abfdabe5a56fa856e61920d5e2b51e1682978deda35d9a6589d1/matplotlib/matplotlib/issues/10572 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/72ee8ae6ef69abfdabe5a56fa856e61920d5e2b51e1682978deda35d9a6589d1/matplotlib/matplotlib/issues/10572 |
| og:image:alt | Bug report Bug summary When setting levels that span a wider range of values than the data set, contourf correctly picks the right colors to fill the areas between the contour lines. contour does n... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | boeleman |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9d78ea552aac0685ca5f006d44f88166cbbf3bb96843f8da0c5a2c0b9908430b |
| 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 | 160a6fceec0fef718a0c3ac46f2d71ae9d5c0ff5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width