Fix contour behavior when Z is constant (zmin == zmax)#31534
Fix contour behavior when Z is constant (zmin == zmax)#31534manasvi-sahare wants to merge 1 commit intomatplotlib:mainfrom
Conversation
|
Hi @manasvi-sahare , please update the PR description to correctly include the filled PR template, especially the AI disclosure section. Thanks |
|
⏰ This pull request might be automatically closed in two weeks from now. Thank you for your contribution to Matplotlib and for the effort you have put into this PR. This pull request does not yet meet the quality and clarity standards needed for an effective review. Project maintainers have limited time for code reviews, and our goal is to prioritize well-prepared contributions to keep Matplotlib maintainable. Matplotlib maintainers cannot provide one-to-one guidance on this PR. However, if you ask focused, well-researched questions, a community member may be willing to help. 💬 To increase the chance of a productive review:
As the author, you are responsible for driving this PR, which entails doing necessary background research as well as presenting its context and your thought process. If you are a new contributor, or do not know how to fulfill these requirements, we recommend that you familiarize yourself with Matplotlib's development conventions or engage with the community via our Discourse or one of our meetings before submitting code. If you substantially improve this PR within two weeks, leave a comment and a team member may remove the |
Fixes #31493.
This PR addresses an issue where contour/contourf produces invalid or misleading output when the input data is constant (i.e., zmin == zmax).
Problem
When Z is constant, the automatic level generation in
_autolevpasses identical values to the locator, which results in invalid or non-informative contour levels.Changes
_autolevto detect the casezmin == zmaxUserWarningindicating that contour levels are not meaningful for constant data[zmin]) to prevent downstream errorsBehavior
Testing
Added a test case in
test_contour.pyto verify: