How to hide the axes in front of 3D plots

14 次查看(过去 30 天)
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.

Community Treasure Hunt

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

Start Hunting!

Translated by