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

1 Ansicht (letzte 30 Tage)
Atom
Atom am 11 Jun. 2022
Kommentiert: Atom am 12 Jun. 2022
()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 Kommentare
Image Analyst
Image Analyst am 12 Jun. 2022
I guess he wants just the convex hull points, like from convhulln

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Star Strider
Star Strider am 11 Jun. 2022
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 am 11 Jun. 2022
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.

Kategorien

Mehr zu Discrete Data Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by