How to set axis of scatter3?

조회 수: 22 (최근 30일)
Michael Feeley
Michael Feeley 2015년 10월 12일
편집: Walter Roberson 2025년 1월 14일
Hi, I have a for loop that basically continuously plots points using drawnow corresponding to particles in an explosion. So far, I've got the 3D scatter plot to continuously graph the explosion, its just that the axis continually readjusts every couple iterations, and the point motion is distorted because of it. Is there any way to set the axis of scatter3D? I've checked online everywhere and couldn't find an answer. Axis() doesn't seem to do anything. Thanks

채택된 답변

the cyclist
the cyclist 2015년 10월 12일
Here is an example with unfixed axes, and fixed axes:
% Unfixed axes
figure
for N = 1:10
pause(0.5)
[X,Y,Z] = sphere(16);
r = rand(1);
X = 5*r*X;
Y = 5*r*Y;
Z = 5*r*Z;
x = [0.5*X(:); 0.75*X(:); X(:)];
y = [0.5*Y(:); 0.75*Y(:); Y(:)];
z = [0.5*Z(:); 0.75*Z(:); Z(:)];
scatter3(x,y,z)
end
% Fixed axes
figure
for N = 1:10
pause(0.5)
[X,Y,Z] = sphere(16);
r = rand(1);
X = 5*r*X;
Y = 5*r*Y;
Z = 5*r*Z;
x = [0.5*X(:); 0.75*X(:); X(:)];
y = [0.5*Y(:); 0.75*Y(:); Y(:)];
z = [0.5*Z(:); 0.75*Z(:); Z(:)];
scatter3(x,y,z)
set(gca,'XLim',[-3 3],'YLim',[-3 3],'ZLim',[-3 3])
end
  댓글 수: 2
Michael Feeley
Michael Feeley 2015년 10월 12일
Actually this worked well! Thanks
Sophie
Sophie 2025년 1월 14일
편집: Walter Roberson 2025년 1월 14일
Hello there,
I´ve computed a 3D plots to demonstrate the idea of linesearch and I want to have the view (-86,35) but if I do so, the outer black frame is distorted as well as the points I´ve computed with
plot3(xk(1),xk(2),fk+foff,'o','LineWidth',4,'Color',acinred)
I´ve thought that these commands will help:
set(gca,'XTick',[],'YTick',[],'ZTick',[])
box on
but the problem still occurs... does anyone know what might be the problem? I´ve tried axis equal, but that doesn´t help at all.
Thanks in advance,
Sophie

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

추가 답변 (1개)

Thorsten
Thorsten 2015년 10월 12일
axis([your values])
hold on
  댓글 수: 1
Michael Feeley
Michael Feeley 2015년 10월 12일
This seemed to work for the axis, but it slowed the plotting significantly. I'm trying to plot 1000 particles over thousands of timesteps. I also tried the below method but similar results

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by