Feature Request: Wireframe 3dplot colormap · Issue #3562 · matplotlib/matplotlib · GitHub
Skip to content

Feature Request: Wireframe 3dplot colormap #3562

Description

@hughesadam87

Problem

Currently, ax.plot_wireframe() does not support a colormap; however, this is a very important use case for waterfall plots in spectroscopy.

A workaround was recently implemented in stackoverflow:

http://stackoverflow.com/questions/24909256/how-to-obtain-3d-colored-surface-via-python/26026556#26026556

However, this workaround does not work in the case for datasets in which X and Y are not of the same dimension. For example, if X is 100 points and Y is 50 points and Z(X,Y) is of shape (100X50) the workaround will fail.

I've looked into it, and the workaround fails because it depends on LineCollection._segment3d. In the case of equally space data (len(X) = len(Y)), _segment3d is ndim=3; otherwise it is ndim=1. This is the expected behavior of converting a list of list into a numpy array. plot_wireframe() passes a list of lists into LineCollection, and doing np.array() on a list of list will return a 1d array when the lists are of unequal length.

Ideas

To fix this either requires changing how plot_wireframe() sends data into LineCollection3d. If it were to pass an array-object somehow instead of a list of lists, this might alleviate the behavior. Alternatively, perhaps LineCollection._store3d could be expanded to handle this case.

Use cases

I'd expect both of these to work:

ax.plot_wireframe(X, Y, Z, cmap='jet')

and

wires = ax.plot_wireframe(X, Y, Z)
wires.set_cmap('jet')
#would wire.set_array() still be necessary?  

PS, this might be worth combining with related: #3554 . The resulting product could produce plots like this one from mathworks: http://www.mathworks.com/help/matlab/ref/waterfall_1.png

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions