rotate a 3D plot and keep it the same size
Mostrar comentarios más antiguos
I'm creating a GIF from a series of 3D plots, each one rotated from the previous by changing the viewpoint. Here is a snippet that does the frame generation:
for az=0:5:355
view([az,el]);
drawnow;
frame = getframe(gcf);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite(imind,cm,filename,'WriteMode','append','DelayTime',dt);
end
The problem I'm having is that each frame is magnified to fill the figure window, causing the plot to change size as it rotates. Here is a link to the GIF (it is also attached).
What view settings must I change to keep the 3D surface the same apparent size as I rotate it?
4 comentarios
Krisztian Szucher
el 25 de Sept. de 2017
Editada: Krisztian Szucher
el 25 de Sept. de 2017
With the gca command, you can get a handle for the current axes
k = gca
now you can use
inspect(k)
to see what settings are available. I'd suggest experimenting with the CameraViewAngle/Mode and PlotBoxAspect/Ratio properties from the inspector, to see if changing them result in the desired outcome.
Once you've figured out, you can use dot notation to set those parameters from code, e.g.
k.CameraViewAngleMode = 'manual'
Michael Krumin
el 18 de Nov. de 2017
Hi,
The relevant axis properties are: 'CameraTarget', 'CameraPosition', 'CameraViewAngle', and 'CameraViewAngleMode'.
If you change the 'viewing orientation' of the 3D plot using view(az, el), then the distance of the camera from your 3D object doesn't change, and you only need to set 'CameraViewAngle' to control the 'zoom'. After you set it once, then the 'CameraViewAngleMode' becomes 'manual', and the 'CameraViewAngle' doesn't change on every call to view(az, el), so no need to reset it for every frame.
Juan Diez Albar
el 21 de Ag. de 2020
This piece of advice worked for me. Thank you soooooo much, Sir.
Respuesta aceptada
Más respuestas (1)
KSSV
el 25 de Sept. de 2017
0 votos
Read about axis, with this you can limit the axis. Also read about xlim, ylim and zlim with these you can set the limits of specific axes.
2 comentarios
KSSV
el 25 de Sept. de 2017
Try converting your az and el to Cartesian using pol2cart and specify viewpoint by view([x y z]). With z as your desired value.
Categorías
Más información sobre Graphics Performance en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!