Plotting a 3D surface on the XZ plane
Show older comments
I've got some 3D surface data I want to visualise, which I've been using the surf(X,Y,Z) function for. This creates a 'horizontal' surface in the XY plane. However, some of the 3D data I am visualising describes a 'vertical' surface (like a wall), and so I would like to plot it in the XZ plane, with the y values being depth.
I have tried plotting the data as a 'horizontal' XYZ surface and rotating the view - but because of how 'surf' works this will only provide a 2D view with no depth element (Matlab will only provide a 3D view from 'above'). You can of course create a surface by swapping the depth and height axes (i.e. plot surf(X,Z,Y)), but this still only creates a surface in the XY plane with Z depth values. I want to create a surface in the XZ plane, with Y values. Any ideas?
Answers (1)
Star Strider
on 20 Jan 2017
4 votes
I’m not certain what you’ve already done. I would use the rotate (link) function. You might have to re-label your axes later, but that is relatively straightforward.
4 Comments
Lewis2s6d
on 20 Jan 2017
Star Strider
on 20 Jan 2017
I didn’t notice that originally.
When I ran the demo code and specified the axis to scale the colours by, the colours remained in the rotated figure.
Example:
[X,Y,Z] = peaks(25);
C = Z;
figure(1)
subplot(1,2,1)
surf(X,Y,Z)
axis tight
subplot(1,2,2)
hSurface = surf(X,Y,Z,C);
direction = [1 0 0];
rotate(hSurface,direction,90)
axis tight

Experiment with that with your data.
Luis Botton
on 5 Jul 2018
Thanks
Star Strider
on 5 Jul 2018
My pleasure.
A vote would be appreciated!
Categories
Find more on Surface and Mesh Plots 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!