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

3 ビュー (過去 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
Atom
Atom 2022 年 6 月 12 日
The interior is like as the post of Image Analyst (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.
  1 件のコメント
Atom
Atom 2022 年 6 月 11 日
編集済み: Atom 2022 年 6 月 11 日
No..it is not working

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by