Multiple 2-D area plots in a 3-D graph
조회 수: 15 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (3개)
Star Strider
2014년 6월 14일
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
Image Analyst
2014년 6월 14일
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
2014년 6월 14일
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.
krishna teja
2020년 4월 14일
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')
riccardo
2014년 6월 14일
편집: Star Strider
2014년 6월 14일
댓글 수: 1
Star Strider
2014년 6월 14일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Exploration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!