-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Feature Request: Wireframe 3dplot colormap #3562
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@tacaswell - I wonder if it is a bad idea to put this into a milestone like this - the label tells us it is a wishlist item, so it would get done if we had enough time, but the truth is, the lack of this feature wouldn't hold us back from an actual v1.5.x release. I'd be comfortable, if you want all issues to be milestoned, to have a |
Fair enough. My view was that mile stones are flexible and make heavy use of punting to the next milestone, but I see why that is a bad thing. |
PS, I know this is a low priority, but if anyone has an outlined solution in mind, I can give it a shot. |
Reading through your explanation, it makes me wonder if the problem is that _segments3d has different dimensionality in different cases. I can't remember for sure, but I don't think that is intentional (although, I can't imagine segments3d working as 1d -- did you mean 2d?). |
_segments3d is created through through a call to
In the example workaround I posted, the user starts with X, Y mesh that is the same number of points; each has 100 points:
This results in a
When I go and use my own data where X has 704 points, Y has 100 points and Z is 704 x 100, I get X, Y and Z as (704,100) shape. However,
See, it's a 1D array of 83 items. However, each item is a (120,3) array:
This is merely the behavior of See, it's a 1D array of 83 items. However, each item is a (120,3) array:
I'd posit that if instead it returned an (83, 120, 3) array, everything would work peachy. It doesn't seem intentional, as np.asanyarray() has this dual behavior. When I try to reshape the array, I can't!
|
Holy crap! That is definitely not intended behavior. What version of Numpy On Fri, Oct 3, 2014 at 12:46 PM, Adam Hughes notifications@github.com
|
1.8.2 I looked into it and it did seem to be the intended behavior of numpy; however, I can't find the discussion on the subject now that I'm looking for it again. Ya, it's wonky! |
Well, more specifically, it might be an issue with the broadcasting. The input to asanyarray might be slightly malformed. It is entirely a coincidence that it would seem to work fine because, ultimately, the result could be represented as a perfectly normal 3d array (I am assuming that |
I'm not sure. It turns out that each row in wire._segment3d is not an array, but a list! It's a 1-d array of 83 lists! I doubt anyone calling "asanyarray" intended for a 1d array of nested lists! I also mispoke, the 1D array is not of shape (120,3) it's of shape (100,3). I created a reproducible example on a small 5x5 mesh. Change the "RDIM" or "CDIM" attributes to be unequal (for example RDIM = 4) to get the errant behavior. This still incorporates the workaround.
|
If we were able to get the segments3d to return the numpy array of correct dimension, do you think adding colormap support would be simple, or would that require a lot of non-trivial steps as well? |
I think it would be rather simple On Mon, Oct 6, 2014 at 2:57 PM, Adam Hughes notifications@github.com
|
Hey guys. I did some followup on this, and found out that it's not really MESH: 2 x 2
Len 4 list. Each element is a list of 2 tuples. Each tuple is 3 elements.
This gives a nice array of correct shape.
MESH: 2x3
Len 4 list. First two elements are list of 2 tuples. Second two are a list of 3 tuples!! Each tuple is 3 elements. Segments is asymmetric, so of course np.array() is not going to cast it nicely. Any idea of if this is the way it should be for a non-symmetric mesh? |
PS, I made a spectroscopy 2d/3d plotting tutorial where I interface all of the mpl 3d plots for spectroscopy. I used a slice of the data so you can see how I'd envision the colormaps to work, and why I'm obviously eager to figure out this issue. Thought it would make a cool demo for 3d MPL: |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
I believe this can be done with the |
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 intoLineCollection
, and doingnp.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:
and
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
The text was updated successfully, but these errors were encountered: