Plot 2d colored image on a 3d space
Show older comments
I have a set of .xyz data files where x and y are cooredinates and z is the value given to each coordinate (resistivity). Using the surf function as the code below dipicts I am able to see a 3d colored image of the resistivity at each location. Using view (30,90) I can see it's projection onto 2d space. However, what I want is slightly different than what view outputs. We know in reality to each (X,Y) coordinate a certain height can be associated. So I want the 2d colored output of view to be plotted on a 3d space where the z axis indicates the variable height, and not the colorbar. How to do this?
%b is a M by 3 matrix
x=b(:,1);
y=b(:,2);
z=b(:,3);
N = 250;
xvec = linspace(min(x), max(x), N);
yvec = linspace(min(y), max(y), N);
[X, Y] = ndgrid(xvec, yvec);
F = scatteredInterpolant(x, y, z);
Z = F(X, Y);
surf(X, Y, Z, 'edgecolor', 'none');
colormap default
colorbar
%view(0,90)
2 Comments
Walter Roberson
on 21 Aug 2021
When you use that code, the Z axis is going to indicate the height.
The output is also going to be colored, with the range of Z values divided by the number of entries in the colormap and the color index being proportionate to the fraction of the Z range.
If you do not want the output to be colored that way, then use a different colormap, such as
colormap gray
James Mathio
on 21 Aug 2021
Answers (1)
Walter Roberson
on 21 Aug 2021
1 vote
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!