matplotlib / matplotlib/matplotlib
Feature Request: Wireframe 3dplot colormap
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 23.2k
- Forks
- 8.5k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 66
Description
## 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at plot_wireframe() and trace how its data reaches LineCollection, especially _segment3d and _store3d. Review related issue #3554 and the unequal-dimension example first. Done means wireframes support colormaps for both direct cmap use and set_cmap(), including X and Y with different lengths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100