Perspective problem in 3D plots with shared axes

3 vues (au cours des 30 derniers jours)
Mikel Quintana Uriarte
Mikel Quintana Uriarte le 20 Déc 2021
Commenté : DGM le 16 Fév 2024
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!!!

Réponses (1)

Pavan Sahith
Pavan Sahith le 16 Fév 2024
Modifié(e) : Pavan Sahith le 16 Fév 2024
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 commentaire
DGM
DGM le 16 Fév 2024
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.

Connectez-vous pour commenter.

Produits


Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by