Why are title and x/y lable not listed in Children property of axes?

Hi there,
I tried
>> allchild(ax)
ans =
6x1 graphics array:
Group
Line
Line
Line
Line
Line
which is supporsed to list all, including hidden children of axes. However it turns that there were only 5 lines that I draw and a empty group.
>> ax.Children(1)
ans =
Group with properties:
Children: [0x0 GraphicsPlaceholder]
Visible: 'on'
HitTest: 'on'e
So could someone help to expain why title and x/y lables are gone? If you do
Title.Parent
ans =
Axes
How come it is not a Children of axes while at same time its parent is axes?
And also why can't I get the handle of a title by using
gco
ans =
0x0 empty GraphicsPlaceholder array.
when Title is obviously an object (primitive.Text)
Thanks so much for help!

 Réponse acceptée

Steven Lord
Steven Lord le 1 Juin 2016
The title handle and the handles to the axes labels are stored in properties Title, XLabel, YLabel, and ZLabel in the axes rather than being Children of the axes. See the "Title and Axes Labels" section in the Axes Properties documentation for more information, including a Note that states they are not Children of the axes.

6 commentaires

Hi Steven, I understood what you said but that didn't quite answer my question. I've rephrase my question to make it clearer. Thank you!
Parent and Children aren't exact opposites, and they're not exactly what you may think of (a family tree) when you think of those terms.
As an analogy think of you, your son or daughter, and your spleen instead of the axes, a line, and the axes title. Your son or daughter (the line) is in your (the axes) Children property and you are in their Parent property. Your spleen (the axes title) is not in your Children property, but you (the axes) are in its Parent property.
Thanks Steven! Really impressive analogy. But is there a way to create a handle for existing title? It seems "gco" function doesn't work on it.
A Title is a handle object already. To access it retrieve the Title property of the axes.
ax = axes;
t = ax.Title;
Another way to retrieve the title handle is to call the title function with an output argument.
I would personally avoid gco as it can too easily change without you realizing it. Clicking in a different location in the figure or in a different figure can change it.
I didn't notice the Title property is a handle itself. Thank you so much for improving my understanding!
But I still don't understand why gco returns an empty graphic place holder on title and x/y label? Are they a little bit special compared with ordinary graphic objects?

Connectez-vous pour commenter.

Plus de réponses (2)

Jan Orwat
Jan Orwat le 1 Juin 2016
The answer is that those aren't axes children. Here is documentation page that mention it: Graphics Objects
Quote: Note: An axes is a single object that represents x-, y-, and z-axis scales, tick marks, tick labels, axis labels, and so on.

1 commentaire

Hi Jan, I understood what you said but that didn't quite answer my question. I've rephrase my question to make it clearer. Thank you!

Connectez-vous pour commenter.

David
David le 11 Juil 2016
Related question, how about the title of a colorbar? I can access it with get(h,'title'), where h is the handle to a colorbar, but if I look at h's properties, there's no 'title' there. What's the deal?

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by