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

조회 수: 15 (최근 30일)
riccardo
riccardo 2014년 6월 14일
댓글: Ziao ZHANG 2021년 4월 21일
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?

답변 (3개)

Star Strider
Star Strider 2014년 6월 14일
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
Image Analyst
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
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
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')
  댓글 수: 1
Ziao ZHANG
Ziao ZHANG 2021년 4월 21일
thanks exactly what i need! thank you

댓글을 달려면 로그인하십시오.


riccardo
riccardo 2014년 6월 14일
편집: Star Strider 2014년 6월 14일
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
Star Strider
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 CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by