Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: Allow RGB(A) arrays for pcolormesh#24619

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ksunden merged 2 commits intomatplotlib:mainfromgreglucas:pcolormesh-rgba
Dec 5, 2022

Conversation

greglucas
Copy link
Contributor

@greglucasgreglucas commentedDec 4, 2022
edited
Loading

PR Summary

Allow a user to set the array values to explicit colors with RGB(A) values in the 3rd dimension. We already usemcolors.to_rgba() to set the facecolors and that will do the RGB(A) handling for us as long as we use 3D arrays. i.e. we can't handle(h*w, 4) flattened arrays with colors.

closes#4277
closes#24418
closes#22236 (separate commit to handle pcolorfast in case we want this as a separate PR)

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (andpytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a.. versionadded:: directive in the docstring and documented indoc/users/next_whats_new/
  • API changes are marked with a.. versionchanged:: directive in the docstring and documented indoc/api/next_api_changes/
  • Release notes conform with instructions innext_whats_new/README.rst ornext_api_changes/README.rst

PrometheusPi reacted with rocket emoji
Allow a user to set the array values to explicit colors with RGB(A)values in the 3rd dimension.
@tacaswell
Copy link
Member

I'm honestly surprised that this was mostly removing / modifying input validation code.

@greglucas
Copy link
ContributorAuthor

I'm honestly surprised that this was mostly removing / modifying input validation code.

This is really helped out by moving the QuadMesh coordinates and array towards accepting 2D inputs and this being an extension of that.

@ksundenksunden merged commitd46c27a intomatplotlib:mainDec 5, 2022
C = C.ravel()
# convert to one dimensional array, except for 3D RGB(A) arrays
if C.ndim != 3:
C = C.ravel()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why do 3-D arrays not need to be flattened at all?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

or conversely, why are we flattening 2-D arrays?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes, I am not a fan of the flattening either... Allowing 2-D arrays is pretty new (only the last couple of releases), so everyone always used to have to flatten their arrays before getting/setting arrays. Unfortunately, that is baked into a few of our tests as expecting to pass a 2-D array in, and then callingmesh = plt.pcolormesh(z2d); mesh.get_array() == z2d.ravel(). I don't think we should be messing with people's arrays if they pass them in as 2D, but that may be too controversial to change at this point too...

Copy link
ContributorAuthor

@greglucasgreglucasDec 5, 2022
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why do 3-D arrays not need to be flattened at all?

Specifically for 3-D, we can not flatten them because the image RGB(A) color handling code will only handle the 3-D shapes of(M, N, [3 or 4])

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jklymakjklymakjklymak left review comments

@tacaswelltacaswelltacaswell approved these changes

@ksundenksundenksunden approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.7.0
Development

Successfully merging this pull request may close these issues.

[ENH]: rgp or rgba option for pyplot pcolormesh and/or pcolor [Bug]: integer colours for pcolorfast / quadmesh RGB not supported in pcolormesh
4 participants
@greglucas@tacaswell@jklymak@ksunden

[8]ページ先頭

©2009-2025 Movatter.jp