-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Make pcolor more mesh-like #25027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Make pcolor more mesh-like #25027
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
The object returned by ``pcolor()`` has changed to a ``PolyQuadMesh`` class | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
The old object was a `.PolyCollection` with flattened vertices and array data. | ||
The new `.PolyQuadMesh` class subclasses `.PolyCollection`, but adds in better | ||
2D coordinate and array handling in alignment with `.QuadMesh`. Previously, if | ||
a masked array was input, the list of polygons within the collection would shrink | ||
to the size of valid polygons and users were required to keep track of which | ||
polygons were drawn and call ``set_array()`` with the smaller "compressed" array size. | ||
Passing the "compressed" and flattened array values is now deprecated and the | ||
full 2D array of values (including the mask) should be passed | ||
to `.PolyQuadMesh.set_array`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
``PolyQuadMesh`` is a new class for drawing quadrilateral meshes | ||
---------------------------------------------------------------- | ||
|
||
`~.Axes.pcolor` previously returned a flattened `.PolyCollection` with only | ||
the valid polygons (unmasked) contained within it. Now, we return a `.PolyQuadMesh`, | ||
which is a mixin incorporating the usefulness of 2D array and mesh coordinates | ||
handling, but still inheriting the draw methods of `.PolyCollection`, which enables | ||
more control over the rendering properties than a normal `.QuadMesh` that is | ||
returned from `~.Axes.pcolormesh`. The new class subclasses `.PolyCollection` and thus | ||
should still behave the same as before. This new class keeps track of the mask for | ||
the user and updates the Polygons that are sent to the renderer appropriately. | ||
|
||
.. plot:: | ||
|
||
arr = np.arange(12).reshape((3, 4)) | ||
|
||
fig, ax = plt.subplots() | ||
pc = ax.pcolor(arr) | ||
|
||
# Mask one element and show that the hatch is also not drawn | ||
# over that region | ||
pc.set_array(np.ma.masked_equal(arr, 5)) | ||
pc.set_hatch('//') | ||
|
||
plt.show() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this file getting hit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc build was complaining about inherited private members (if I remember correctly). This file is automatically generated, so there are also other missing references that have been updated unrelated to this PR:
matplotlib/doc/conf.py
Lines 184 to 185 in f588d2b