How to preserve the 3d plot box, when changing patch visibility.

I have a 3d plot with a collection of patches. If I set a subset of patches Visible attributes to 'off', the plot box is recomputed. How can I capture and preserve all aspects of the plot box so that the visible patches don't jump around as other patches become visible or invisible.

Respuestas (2)

Matt J
Matt J el 11 de Mzo. de 2026 a las 2:53
Editada: Matt J hace alrededor de 9 horas
Using axis() twice, we can both capture and reassert the axis limits,
axis(axis)
This also then converts all X,Y,ZLimModes to 'manual' so automatic changes will not happen.
Voss
Voss hace alrededor de 18 horas
Editada: Voss hace alrededor de 18 horas
You don't need to capture anything.
To preserve the axes limits as they are, set the axes XLimMode, YLimMode, and ZLimMode to 'manual'. Obviously you would do that at a point in the code where the axes limits are what you want them to be, e.g., after all patches are initialized.
Other axes properties besides the limits affect the plot box, so you may want to set some other properties' modes to 'manual' as well in order to disable all undesired automatic changes to the plot box, e.g., PlotBoxAspectRatioMode, CameraViewAngleMode, etc. Look through the axes properties to see what you have control over:

3 comentarios

It seems I do need to capture previous values because setting the ?LimMode's causes the limits to change.
See below how the ZLim values change when the YLimMode is set.
>> [ax.XLim, ax.YLim, ax.ZLim]
ans =
-0.1561 6.1561 1.0000 5.0000 0.5000 5.5000
>> ax.XLimMode = 'manual';
>> ax.YLimMode = 'manual';
>> [ax.XLim, ax.YLim, ax.ZLim]
ans =
-0.1561 6.1561 1.0000 5.0000 1.0000 5.0000
Voss
Voss hace alrededor de 9 horas
Interesting

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Object Programming en Centro de ayuda y File Exchange.

Productos

Versión

R2025b

Preguntada:

el 11 de Mzo. de 2026 a las 2:38

Comentada:

hace alrededor de 12 horas

Community Treasure Hunt

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

Start Hunting!

Translated by