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

1 次查看(过去 30 天)
()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 个评论

请先登录,再进行评论。

回答(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