필터 지우기
필터 지우기

How to move the axes so that they start from the center of the sphere (0,0,0)

조회 수: 4 (최근 30일)
Atom
Atom 2022년 6월 11일
댓글: Atom 2022년 6월 12일
()1 How to move the axes so that they start from the center of the sphere (0,0,0)
(2) If I only want to keep the boundary curve and remove the interiors, what to do?
R = 1 ;
theta = linspace(0,2*pi) ;
phi = linspace(0,pi) ;
[T,P] = meshgrid(theta,phi) ;
X1 = R*cos(T).*sin(P) ;
Y1 = R*sin(T).*sin(P) ;
Z1 = R*cos(P) ;
zlim([0,5])
surf(X1,Y1,Z1,'EdgeColor','r', 'FaceColor', 'none', 'FaceAlpha', .5) ;
  댓글 수: 5
Image Analyst
Image Analyst 2022년 6월 12일
I guess he wants just the convex hull points, like from convhulln

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

답변 (2개)

Star Strider
Star Strider 2022년 6월 11일
Try something like this —
R = 1 ;
theta = linspace(0,2*pi) ;
phi = linspace(0,pi) ;
[T,P] = meshgrid(theta,phi) ;
X1 = R*cos(T).*sin(P) ;
Y1 = R*sin(T).*sin(P) ;
Z1 = R*cos(P) ;
zlim([0,5])
surf(X1,Y1,Z1,'EdgeColor','r', 'FaceColor', 'none', 'FaceAlpha', .5, 'EdgeAlpha',0.5) ;
hold on
plot3([0 0],[0 0],zlim, '-k', 'LineWidth',1.5)
xline(0, '-k', 'LineWidth',1.5)
yline(0, '-k', 'LineWidth',1.5)
Ax = gca;
xt = Ax.XTick;
yt = Ax.YTick;
zt = Ax.ZTick;
Ax.Visible = 'off';
plot3([xt; xt], ones(2,numel(xt)).*[-1;1]*0.1, zeros(2,numel(xt)), '-k')
plot3(ones(2,numel(xt)).*[-1;1]*0.1, [yt; yt], zeros(2,numel(xt)), '-k')
plot3(ones(2,numel(xt)).*[-1;1]*0.1, zeros(2,numel(xt)), [zt; zt], '-k')
hold off
text(xt, zeros(size(xt)), zeros(size(xt)), compose(' %.1g',xt), 'Horiz','left', 'Vert','middle', 'Rotation',-35)
text(zeros(size(yt)), yt, zeros(size(yt)), compose(' %.1g',yt), 'Horiz','left', 'Vert','middle', 'Rotation',30)
text(zeros(size(zt)), zeros(size(zt)), zt, compose(' %.1g',zt), 'Horiz','left', 'Vert','middle', 'Rotation',-10)
axis('equal')
.

Image Analyst
Image Analyst 2022년 6월 11일
The usual way is
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
However it doesn't seem to work for this 3-D plot. Not sure why. It does work for 2-D plots though.

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by