How do I plot different x-y plots stacked one behind another in MATLAB?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have two 2-D plots that I would like to stack, one behind the other, to form a 3-D plot.
Respuesta aceptada
MathWorks Support Team
el 27 de Jun. de 2009
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!