Borrar filtros
Borrar filtros

MATLAB GUI - How can I get programmatically whether an 'axis' object is empty or not?

7 visualizaciones (últimos 30 días)
I have a MATLAB GUI, in which there is a figure (an 'axis' object). I would like to know programmatically whether there is or not a plot in that figure/axis, because I would like to add an 'axis limit' control. The code would be:
if figure_is_empty
axis([xMin xMax yMin yMax])
else
don't do anything, because there is nothing to 'resize'
end
Any suggestion?

Respuestas (1)

Jan
Jan el 23 de Sept. de 2013
The objects are called "axes" with "e".
If an axes contains any object, you find it in the list of its children:
isEmpytAxes = isempty(get(AxesHandle, 'Children'))
How the AxesHandle can be obtained depends on the details of your program.
The emptiness of a figure is something else: It means that the figure does not contain axes objects, buttons, menus etc. Notice that children can be hidden also, then allchild is useful:
allchild(gcf)
  1 comentario
Ahmed Ali
Ahmed Ali el 26 de Ag. de 2022
Editada: Ahmed Ali el 26 de Ag. de 2022
isEmpytAxes = isempty(get(AxesHandle, 'Children'))
Worked fine..thank you.

Iniciar sesión para comentar.

Categorías

Más información sobre Specifying Target for Graphics Output 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