Why is the Tag property of the parent axes not retained when using the IMSHOW function?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 22 Jan 2010
Modifié(e) : MathWorks Support Team
le 3 Août 2016
I have set a value to the Tag property of an axes. I then display another image using the IMSHOW command with the 'Parent' property set to the first axes. However, the Tag property of the first axes is not retained.
An example is provided below:
load spine;
imshow(X,map);
set(gca,'Tag','spineImagehere')
get(gca,'Tag') % Tag property has been set
imshow(X,map,'Parent',gca)
get(gca,'Tag') % Tag property does not exist
Réponse acceptée
MathWorks Support Team
le 3 Août 2016
This is expected behavior. The IMSHOW function internally creates a new plot. Since the axes "NextPlot" property to set to "replace" (the default), all the axes properties are reset (except for the 'Position' property) to their default values and all axes children are deleted before displaying graphics.
In order to change this behavior, set the "NextPlot" property of the axes to "add".
The MATLAB code incorporating this change is provided below:
load spine;
imshow(X,map);
set(gca,'Tag','spineImagehere')
get(gca,'Tag')
set(gca,'NextPlot','add')
imshow(X,map,'Parent',gca)
get(gca,'Tag') % Tag is retained
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!