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
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
추가 답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!