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