Multiple 2-D area plots in a 3-D graph

34 vues (au cours des 30 derniers jours)
riccardo
riccardo le 14 Juin 2014
Commenté : Ziao ZHANG le 21 Avr 2021
Hi everyone! I need to plot several 2-D (positive)curves orthogonal to the "x,y plane" in a 3-D plot and I would need to fill the area beneath each 2-D curve. In other words, each filled 2-D graph should lie in an plane orthogonal to "x,y" and the projection of each filled graph should be a different line in the "x,y" plane (not necessarily parallel to each other). Does it exist a matlab function for this sort of task?
I already tried with "fill3". It plots the orthogonal 2-D filled curves but I don't know how to set the curve in the z-axis to an arbitrary function instead of just a straight line.
figure
X = [0 0;1 -0.5;1 -0.5];
Y = [0 0;1 -0.3;1 -0.3];
Z = [0 0;0 0;0.5 0.5];
C = [1.0000;
1.0000;
1.0000];
fill3(X,Y,Z,C)
Can anybody help me?

Réponses (3)

Star Strider
Star Strider le 14 Juin 2014
You may want to experiment with the area plot:
x = linspace(0,10);
figure(1)
area(x, sin(0.5*pi*x).^2, 'FaceColor',[0 0 1])
hold on
area(x, 2+10*exp(-((x+5).^2)*10)+sin(7*pi*x)*1, 'BaseValue', 2, 'FaceColor',[1 0 0])
area(x, 4+10*exp(-((x+5).^2)*10)+sin(sin(0.5*pi*x)*3*pi)*1, 'BaseValue', 4, 'FaceColor',[0 1 0])
hold off
  2 commentaires
Image Analyst
Image Analyst le 14 Juin 2014
riccardo's "Answer" moved here:
Thanks for the suggestion. I have already tried with "area" plot but all the "area" plots lay in the "x,y" plane. Is there a way to rotate them in a 3-D plot and set them to an arbitrary location in the space? (Not necessarily all parallel to each other)
Star Strider
Star Strider le 14 Juin 2014
I can’t run your code because ‘Polyhedron’ is not defined.
See if the File Exchange (FES) contribution Line Plot 3D will do what you want. I don’t know if it produces the filled areas below the line, but it otherwise may do what you want.
The only other option I can suggest is the bar3 function.

Connectez-vous pour commenter.


krishna teja
krishna teja le 14 Avr 2020
use watefall command
it does exactly same as what you want
Nactions = 5;
Ntime = 5;
x = (1:Nactions); % actions
y = (1:Ntime); % time
[X,Y] = meshgrid(x,y);
z = rand(Ntime,Nactions);
w = waterfall(X,Y,z)
w.EdgeColor = 'b';
w.EdgeAlpha = 0.5;
w.FaceColor = 'b';
w.FaceAlpha = 0.2;
xlabel('actions')
ylabel('time')
zlabel('probabilities')
title('waterfall')
  1 commentaire
Ziao ZHANG
Ziao ZHANG le 21 Avr 2021
thanks exactly what i need! thank you

Connectez-vous pour commenter.


riccardo
riccardo le 14 Juin 2014
Modifié(e) : Star Strider le 14 Juin 2014
Another test I made is the following. What I would need in this case is to fill the area beneath each curve. Any suggestion??
ExtremePoints = [ 1.3 -5.8; -6.2 -3.4; +4.2 5.2; -5.8 -7.7];
P5 = Polyhedron([ 1.3 -5.8; -6.2 -3.4; +4.2 5.2; -5.8 -7.7]);
P5.plot('color', 'lightblue');
hold on;
plot3(x_1, -0.7*x_1, y_1(x_1));
plot3(x_1, x_1, y_1(x_1));
axis auto;
zlim([0, 100])
  1 commentaire
Star Strider
Star Strider le 14 Juin 2014
I can’t run your code because ‘Polyhedron’ is not defined.
See if the File Exchange (FES) contribution Line Plot 3D will do what you want. I don’t know if it produces the filled areas below the line, but it otherwise may do what you want.
The only other option I can suggest is the bar3 function.

Connectez-vous pour commenter.

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