Title: [Doc]: `contour` and `contourf` levels default not specified · Issue #30996 · matplotlib/matplotlib · GitHub
Open Graph Title: [Doc]: `contour` and `contourf` levels default not specified · Issue #30996 · matplotlib/matplotlib
X Title: [Doc]: `contour` and `contourf` levels default not specified · Issue #30996 · matplotlib/matplotlib
Description: Documentation Link https://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.contourf.html Problem levels is specified to be optional but the default value is not specified. Suggested improvement Digging into the code, it seems that _...
Open Graph Description: Documentation Link https://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.contourf.html Problem levels is specified to be optional but the default value is not specified. Suggested improvemen...
X Description: Documentation Link https://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.contourf.html Problem levels is specified to be optional but the default value is not specified. Suggested improvemen...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30996
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Doc]: `contour` and `contourf` levels default not specified","articleBody":"### Documentation Link\n\nhttps://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.contourf.html\n\n### Problem\n\n`levels` is specified to be optional but the default value is not specified.\n\n\n\n\n\n\n### Suggested improvement\n\nDigging into the code, it seems that [`_process_contour_level_args`](https://github.com/matplotlib/matplotlib/blob/ebf9b14f7f41029e2c61dd09cc37dae98a9bc10d/lib/matplotlib/contour.py#L1011C9-L1011C36) is responsible? It calls `_ensure_locator_exists` :\n\n\nhttps://github.com/matplotlib/matplotlib/blob/ebf9b14f7f41029e2c61dd09cc37dae98a9bc10d/lib/matplotlib/contour.py#L957-L975\n\nSo does this mean that `levels=1` gets passed as `MaxNLocator(n_bins=2)` which gives max `n_bins + 1` (3) levels?\n\nAlso in `levels` it is specified:\n\n\u003e If an int n, use [MaxNLocator](https://matplotlib.org/devdocs/api/ticker_api.html#matplotlib.ticker.MaxNLocator), which tries to automatically choose no more than n+1 \"nice\" contour levels between minimum and maximum numeric values of Z.\n\nBut considering we pass `MaxNLocator(N+1)`, is it n+1 or n+2 ?","author":{"url":"https://github.com/lucyleeow","@type":"Person","name":"lucyleeow"},"datePublished":"2026-01-19T11:17:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/30996/matplotlib/issues/30996"}
| 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:0a7dccf6-c814-4613-4f5d-47d67f7c8b0d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DC24:17A244:10350C8:15ED9AE:6A5335F8 |
| html-safe-nonce | 1704ac45f3cb66e2772ed9c325af9a43989c17fb817b5ae0f60b1308bd16eb69 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQzI0OjE3QTI0NDoxMDM1MEM4OjE1RUQ5QUU6NkE1MzM1RjgiLCJ2aXNpdG9yX2lkIjoiNjE0MzE0MjU5MzcxOTk2NjY0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1650f81368aa7cd31abba9cd717efbe2db0329d975b53f9bbf915d842ab5290f |
| hovercard-subject-tag | issue:3829231711 |
| 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/30996/issue_layout |
| twitter:image | https://opengraph.githubassets.com/143e477787dbdcbb2137d285b06f595822db6fb99ceadd7a252e678ca17bdcb9/matplotlib/matplotlib/issues/30996 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/143e477787dbdcbb2137d285b06f595822db6fb99ceadd7a252e678ca17bdcb9/matplotlib/matplotlib/issues/30996 |
| og:image:alt | Documentation Link https://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.contourf.html Problem levels is specified to be optional but the default value is not specified. Suggested improvemen... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lucyleeow |
| 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