Layers of area plots?

5 views (last 30 days)
matteo
matteo on 21 Aug 2017
Answered: Carl on 24 Aug 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

Answers (1)

Carl
Carl on 24 Aug 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.

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!