Layers of area plots?

5 vues (au cours des 30 derniers jours)
matteo
matteo le 21 Août 2017
Réponse apportée : Carl le 24 Août 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

Réponses (1)

Carl
Carl le 24 Août 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.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by