How to hide the axes in front of 3D plots

조회 수: 16 (최근 30일)
Christine
Christine 2014년 11월 5일
편집: Christine 2014년 11월 6일
Hello,
I am doing a 3D plot and always have this annoying axes in front of my data (see image). How can I hide the front part of the axes? Just couldn't find it... Also I would be interested to change the spacing between the single graphs in the waterfall plot. Any idea?
Thank you!
  댓글 수: 1
Christine
Christine 2014년 11월 6일
편집: Christine 2014년 11월 6일
Thanks for the great answers! Each of them was really helpful. I would have liked to accept all of them :)

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

채택된 답변

Orion
Orion 2014년 11월 5일
Hi,
So to remove the annoying box :
box off
and for the spacing, it depends of the definition of your Z data. the more Z is meshed, the more waterfall will plot lines.
with the matlab example : f
igure
[X,Y,Z] = peaks(30);
waterfall(X,Y,Z)
figure
[X,Y,Z] = peaks(90);
waterfall(X,Y,Z)
  댓글 수: 1
Christine
Christine 2014년 11월 5일
Thanks! The 'box off' command takes off the whole box, so in order to still have a kind of box in the background, one has to set the axis limits to a grid line (-1 < radius < 1 and 0 < density < 2.5e19 in my example).
I see that a higher number of plotted profiles will cause the profiles to be closer to each other, as matlab keeps the z-axis (in my example) the same length. But how can I get the plots closer without increasing their number or changing the viewing angle? Is there a possibility to tell matlab to change the aspect ratio of the axes?

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

추가 답변 (2개)

Orion
Orion 2014년 11월 5일
Did you use the waterfall function or plot3 (you mentionned single graph)
in all cases, if you want to play with the spacing you need to modify your yaxis data.
ex1 : plot3
clear
figure;
subplot(121);
x=(0:0.01:10)';
for i = 1:10
y(:,i) = i*ones(size(x));
z(:,i) = i*abs(sin(x));
end
grid;
plot3(x,y,z);
% 2nd figure : spacing .5 along y
subplot(122);
y(:,1:5) = .5*y(:,1:5); % divide y by 2
y(:,6:10) = 2*y(:,6:10); % divide y by 2
plot3(x,y,z);
ex2 : waterfall
figure
subplot(121);
[X,Y,Z] = peaks(20);
waterfall(X,Y,Z);
subplot(122);
Y(1:10,:) = .2 * Y(1:10,:);
Y(11:20,:) = 3 * Y(11:20,:);
waterfall(X,Y,Z);
  댓글 수: 3
Orion
Orion 2014년 11월 5일
ok, so you want to use the dataAspectRatio
[X,Y,Z] = peaks(20);
figure
subplot(121);
waterfall(X,Y,Z);
set(gca,'DataAspectRatio',[1 1 2])
subplot(122);
waterfall(X,Y,Z);
set(gca,'DataAspectRatio',[.5 1 2]);
Christine
Christine 2014년 11월 6일
Great! This is exactly what I was searching for!

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


Mike Garrity
Mike Garrity 2014년 11월 5일
FYI, R2014b added a new BoxStyle property to the axes which controls whether you see those front edges. The default value is 'back', which does exactly what you want here.
To get the old behavior in R2014b, you would do this:
set(gca,'BoxStyle','full')
Regardless of your BoxStyle, the box command will toggle the visibility of the box.
  댓글 수: 1
Christine
Christine 2014년 11월 6일
Thanks, it looks as if it is time for an update :)

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by