Perspective problem in 3D plots with shared axes

4 次查看(过去 30 天)
Hi!
I want to create a figure with two subplots in the following manner:
I want a rotated view of the first subfigure such that the x-axis coincides with the second subfigure. My main problem is that, I cannot find suitable camera orientation, projection, view... etc that leave the x-axis fixed while the y-axis is rotated.
Thanks in advance!!!

回答(1 个)

Pavan Sahith
Pavan Sahith 2024-2-16
编辑:Pavan Sahith 2024-2-16
Hello Mikel,
I assume that you're trying to find a method to manipulate the viewing angle of a 3D plot while maintaining the x-axis orientation.
MATLAB offers a straightforward solution for this with the 'view' function. It sets the azimuth and elevation angles of the camera's line of sight for the current axes.
For better understanding, I am attaching a sample MATLAB code, feel free to rearrange the tiled layout.
t = 0:pi/20:10*pi;
xt1 = sin(t);
yt1 = cos(t);
tiledlayout(1,3)
% Original 3d plot
ax1 = nexttile;
plot3(ax1,xt1,yt1,t)
xlabel('X')
ylabel('Y')
zlabel('Z')
%creating subplot for top view - X and Y axis
ax2 = nexttile;
plot3(ax2,xt1,yt1,t)
xlabel('X')
ylabel('Y')
zlabel('Z')
view(ax2, [0 90]); % Set view for top view
%creating subplot for front view - X and Z axis
ax3 = nexttile;
plot3(ax3,xt1,yt1,t)
xlabel('X')
ylabel('Y')
zlabel('Z')
view(ax3, [0 0]); % Set view for front view
This script will generate a figure with three subplots
  • the original 3D plot
  • Top view : which have the X-axis and Y-axis
  • Front View : which have the X-axis and Z-axis
To know more about the 'view' function , you can refer to the following MathWorks documentation.
You could also try exploring 'rotate' function - https://www.mathworks.com/help/matlab/ref/rotate.html
Hope this will help.
  1 个评论
DGM
DGM 2024-2-16
This doesn't answer the question of how to create an oblique projection of two 2D axes aligned and oriented as shown. Axes objects only support orthographic and perspective projections, so trying to fake it by drawing things in planes in 3D isn't an option -- at least not by any simple means that I can think of off the top of my head. Creating a skewed 2D axes object also isn't an option.

请先登录,再进行评论。

产品


版本

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by