How do I plot different x-y plots stacked one behind another in MATLAB?

조회 수: 4 (최근 30일)
I have two 2-D plots that I would like to stack, one behind the other, to form a 3-D plot.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
You can achieve this by using the PLOT3 function in MATLAB, with different Y-dimensional offsets for each 2-D plot. For example,
% Data
x{1} = (.2:.2:2).';
z{1} = rand(10,1);
x{2} = 1:4;
z{2} = randn(4,1);
% Plotting
figure;
hold on;
for i = 1:length(x)
plot3(x{i}, i*ones(size(x{i})), z{i});
end
hold off;
grid on;
set(gca,'CameraPosition',[-19 -5 5]);
set(gca,'CameraViewAngle',8);
You can also add semi-transparent patches to each plane to distinguish each 2-D plot. Note that this will change the renderer to OpenGL.
axlim = axis;
for i = 1:length(x)
patch(axlim([1 1 2 2]), [i i i i], axlim([5 6 6 5]), [.8 .9 .8], 'FaceAlpha', .4);
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by