# How to move a (x,y) line plot to the z axis?

조회 수: 14(최근 30일)
Cio 2014년 10월 22일
편집: Matt Tearle 2014년 10월 22일
Hi everyone
I have recently got matlab and have been trying to use it to plot some functions. So far, i have been using plot(x,[y0,y1,y2....]) to plot several functions in one 2D plot, how can i move the y lines along the z axis to give a 3d view instead of them overlapping, with spacing long z, (0:7.5:60). So y0 would be at z=0, y1 at z=7.5, y2 at z=15. If the spacing can be filled in aswell to look like a smooth plain. If that makes any sense any help would be welcome. Thank you.
##### 댓글 수: 1표시숨기기 없음
José-Luis 2014년 10월 22일
I don't get it. Can't you just stack your lines in a 2D plot (add an offset to the y values)?

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

### 답변(1개)

Matt Tearle 2014년 10월 22일
편집: Matt Tearle 2014년 10월 22일
Something like this, perhaps?
x = linspace(0,1)';
y1 = cos(2*pi*x);
y2 = x.^2;
y3 = y1.*y2;
ribbon(x,[y1,y2,y3],1)
The "z" values (actually x in MATLAB's world!) are 1, 2, 3,... instead of 0, 7.5, 15,... but that can be faked, if you really need:
ax = gca;
n = (1:3)'; % change the 3 to however many y variables there are
ax.XTick = n;
ax.XTickLabel = num2str(7.5*(n-1));

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

### Community Treasure Hunt

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

Start Hunting!