Why does the same View property for Axes with different PlotBoxAspectRatio result in different views?
I have two axes, of which I’ve linked the View property. The two have different PlotBoxAspectRatio.
When rotating around in 3D, the two plots behave as I expect. You can overlay the orthogonal axes in the figure below and verify that they are visually aligned:
However, when the plots are rotated into a plane view (elevation = 90°), the same azimuth angle results in a different orientation for each plot:
>> get([a1,a2],’View’)
ans =
2×1 cell array
{[45.2690 90]}
{[45.2690 90]}
The plots will align properly when the axes are horizontal or vertical, but become misaligned in between those states. This only happens for plots with different PlotBoxAspectRatio.
What gives? Code to generate the example above is below:
f = figure(‘Color’, ‘w’); % Figure window
% Coordinates of drawn object
ax1 = [-1.0, +1.0, NaN, 0.0, 0.0, NaN, 0.0, 0.0;
0.0, 0.0, NaN, -1.0, +1.0, NaN, 0.0, 0.0;
0.0, 0.0, NaN, 0.0, 0.0, NaN, -1.0, +1.0];
ax2 = [-2.0, +2.0, NaN, 0.0, 0.0, NaN, 0.0, 0.0;
0.0, 0.0, NaN, -1.0, +1.0, NaN, 0.0, 0.0;
0.0, 0.0, NaN, 0.0, 0.0, NaN, -1.0, +1.0];
% Axes 1
a1 = axes(f, ‘Units’, ‘normalized’, ‘OuterPosition’, [0.0,0.0,0.5,1.0]);
plot3(ax1(1,:),ax1(2,:),ax1(3,:), ‘k’, ‘LineWidth’, 1.0)
axis equal vis3d off
rotate3d on
% Axes 2
a2 = axes(f, ‘Units’, ‘normalized’, ‘OuterPosition’, [0.5,0.0,0.5,1.0]);
plot3(ax2(1,:),ax2(2,:),ax2(3,:), ‘k’, ‘LineWidth’, 1.0)
axis equal vis3d off
rotate3d on
% Link view property
link = linkprop([a1,a2],’View’);
Thanks in advance!I have two axes, of which I’ve linked the View property. The two have different PlotBoxAspectRatio.
When rotating around in 3D, the two plots behave as I expect. You can overlay the orthogonal axes in the figure below and verify that they are visually aligned:
However, when the plots are rotated into a plane view (elevation = 90°), the same azimuth angle results in a different orientation for each plot:
>> get([a1,a2],’View’)
ans =
2×1 cell array
{[45.2690 90]}
{[45.2690 90]}
The plots will align properly when the axes are horizontal or vertical, but become misaligned in between those states. This only happens for plots with different PlotBoxAspectRatio.
What gives? Code to generate the example above is below:
f = figure(‘Color’, ‘w’); % Figure window
% Coordinates of drawn object
ax1 = [-1.0, +1.0, NaN, 0.0, 0.0, NaN, 0.0, 0.0;
0.0, 0.0, NaN, -1.0, +1.0, NaN, 0.0, 0.0;
0.0, 0.0, NaN, 0.0, 0.0, NaN, -1.0, +1.0];
ax2 = [-2.0, +2.0, NaN, 0.0, 0.0, NaN, 0.0, 0.0;
0.0, 0.0, NaN, -1.0, +1.0, NaN, 0.0, 0.0;
0.0, 0.0, NaN, 0.0, 0.0, NaN, -1.0, +1.0];
% Axes 1
a1 = axes(f, ‘Units’, ‘normalized’, ‘OuterPosition’, [0.0,0.0,0.5,1.0]);
plot3(ax1(1,:),ax1(2,:),ax1(3,:), ‘k’, ‘LineWidth’, 1.0)
axis equal vis3d off
rotate3d on
% Axes 2
a2 = axes(f, ‘Units’, ‘normalized’, ‘OuterPosition’, [0.5,0.0,0.5,1.0]);
plot3(ax2(1,:),ax2(2,:),ax2(3,:), ‘k’, ‘LineWidth’, 1.0)
axis equal vis3d off
rotate3d on
% Link view property
link = linkprop([a1,a2],’View’);
Thanks in advance! I have two axes, of which I’ve linked the View property. The two have different PlotBoxAspectRatio.
When rotating around in 3D, the two plots behave as I expect. You can overlay the orthogonal axes in the figure below and verify that they are visually aligned:
However, when the plots are rotated into a plane view (elevation = 90°), the same azimuth angle results in a different orientation for each plot:
>> get([a1,a2],’View’)
ans =
2×1 cell array
{[45.2690 90]}
{[45.2690 90]}
The plots will align properly when the axes are horizontal or vertical, but become misaligned in between those states. This only happens for plots with different PlotBoxAspectRatio.
What gives? Code to generate the example above is below:
f = figure(‘Color’, ‘w’); % Figure window
% Coordinates of drawn object
ax1 = [-1.0, +1.0, NaN, 0.0, 0.0, NaN, 0.0, 0.0;
0.0, 0.0, NaN, -1.0, +1.0, NaN, 0.0, 0.0;
0.0, 0.0, NaN, 0.0, 0.0, NaN, -1.0, +1.0];
ax2 = [-2.0, +2.0, NaN, 0.0, 0.0, NaN, 0.0, 0.0;
0.0, 0.0, NaN, -1.0, +1.0, NaN, 0.0, 0.0;
0.0, 0.0, NaN, 0.0, 0.0, NaN, -1.0, +1.0];
% Axes 1
a1 = axes(f, ‘Units’, ‘normalized’, ‘OuterPosition’, [0.0,0.0,0.5,1.0]);
plot3(ax1(1,:),ax1(2,:),ax1(3,:), ‘k’, ‘LineWidth’, 1.0)
axis equal vis3d off
rotate3d on
% Axes 2
a2 = axes(f, ‘Units’, ‘normalized’, ‘OuterPosition’, [0.5,0.0,0.5,1.0]);
plot3(ax2(1,:),ax2(2,:),ax2(3,:), ‘k’, ‘LineWidth’, 1.0)
axis equal vis3d off
rotate3d on
% Link view property
link = linkprop([a1,a2],’View’);
Thanks in advance! figure, axes, 3d plots MATLAB Answers — New Questions