Skip to content

[ENH]: rgp or rgba option for pyplot pcolormesh and/or pcolor #24418

Closed

Description

@PrometheusPi

Problem

The axis argument X and Y in pcolormesh allows to have non-equidistantly spaced data grids which is very useful if you have measured/simulated/etc data on non-simple axes.

imshow on the other hands does not support such non-equidistant axes since the change to version 2. However, it support the use of (N, M, 3) or (N, M, 4) dimensional arrays to encode rgp or rgba data directly. This allows to write routines that encode e.g. 2D dimensional information like (orientation in color, strength in darkness) or 3D date (directly mapped to rgb).

There seems no way to combine both non-equidistant aces and rgb(a) support in matplotlib.

Proposed solution

Would it be possible to add the rgb and rgba options to pcolormesh/pcolor as well?

Or are there other options for tackling this issue?

Is there actual interest in such an option and would it be worth to add code fo it?

Activity

  1. jklymak commented on Nov 10, 2022

    @jklymak
    Member

    Note that you can set facecolors: https://stackoverflow.com/questions/70541279/how-to-pcolormesh-rgba-array-with-2d-x-and-y.

    OTOH, this is a bit silly, and I agree that if we have a 3-D array, we should bypass colormapping and use the colors.

  2. PrometheusPi commented on Nov 11, 2022

    @PrometheusPi
    Author

    Thanks a lot @jklymak, the suggested example from stackoverflow works like a charm.

    Also thanks you for your comment, that you agree that having support for 3D arrays in pcolormesh seems useful or at least consistent with imshow.

  3. added this to the v3.7.0 milestone on Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions