Borrar filtros
Borrar filtros

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

4 visualizaciones (últimos 30 días)
Atom
Atom el 11 de Jun. de 2022
Comentada: Atom el 12 de Jun. de 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 comentarios
Image Analyst
Image Analyst el 12 de Jun. de 2022
I guess he wants just the convex hull points, like from convhulln

Iniciar sesión para comentar.

Respuestas (2)

Star Strider
Star Strider el 11 de Jun. de 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 el 11 de Jun. de 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.

Categorías

Más información sobre Discrete Data Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by