Layers of area plots?

5 visualizaciones (últimos 30 días)
matteo
matteo el 21 de Ag. de 2017
Respondida: Carl el 24 de Ag. de 2017
Hi all,
I have three matrices size 10x3, and I need to plot them with the area plot into three different layers, i.e. something similar to the contourslice example (https://uk.mathworks.com/help/matlab/ref/contourslice.html) where on the x-axis and y-axis I would have the 2-d area plot and on the z-axis the three matrices.
For example, I have the following three matrices with an area plot for each individual variable: A=ones(10,3); B=2*ones(10,3); C=5*ones(10,3);
figure() area(A,'DisplayName','HS') figure() area(B,'DisplayName','HS') figure() area(C,'DisplayName','HS')
How can I layer there three area plots into one plot, as shown by the attached pictures for example?
Thank you, Mat

Respuestas (1)

Carl
Carl el 24 de Ag. de 2017
Hi Matteo. I don't believe there's a way of doing this with the area function, which only operates in 2D. However, you can work around this using the patch function. See the example code below:
xdata = 1:10;
ydata = rand(1,10);
patch([1 xdata 10], [0 ydata 0], ones(12,1), 'b')
patch([1 xdata 10], [0 ydata 0], 2*ones(12,1), 'r')
patch([1 xdata 10], [0 ydata 0], 3*ones(12,1), 'g')
In the resulting figure, you can click the "Rotate 3D" button to examine the plots.

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by