Skip to content

RGB not supported in pcolormesh #4277

Closed
@rwb27

Description

@rwb27

Hello,
When using imshow, it's possible to pass either a 2D array (which is rendered as false color via a colormap) or a 3D array where the last dimension is 3 (or perhaps 4, I've not tested). In the latter case, the data is rendered assuming the last dimension means color, i.e. the data is in RGB format. When using pcolormesh, however, only the first behaviour works; passing RGB data simply results in an error:

Traceback (most recent call last):
  File "C:\Users\Richard\Desktop\2015_02_10_CB7_Nap\test_rgb_idealised.py", line 19, in <module>
    m = plt.pcolormesh(x, y, rgb/255.0, linewidth=0)
  File "C:\Anaconda\lib\site-packages\matplotlib\pyplot.py", line 2946, in pcolormesh
    ret = ax.pcolormesh(*args, **kwargs)
  File "C:\Anaconda\lib\site-packages\matplotlib\axes.py", line 7736, in pcolormesh
    X, Y, C = self._pcolorargs('pcolormesh', *args, allmatch=allmatch)
  File "C:\Anaconda\lib\site-packages\matplotlib\axes.py", line 7351, in _pcolorargs
    numRows, numCols = C.shape
ValueError: too many values to unpack

So, my question is whether pcolormesh should only support false color data, or whether RGB support ought to be included. I found a work-around which I documented here:
http://stackoverflow.com/questions/29232439/plotting-an-irregularly-spaced-rgb-image-in-python/29232668?noredirect=1#comment46710586_29232668

For reference, I'm running v1.3.1 of matplotlib, on Windows (64 bit) via Anaconda.

Thanks,

Richard

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions