Layers of area plots?

3 次查看(过去 30 天)
matteo
matteo 2017-8-21
回答: Carl 2017-8-24
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

回答(1 个)

Carl
Carl 2017-8-24
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.

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by