Why is the Tag property of the parent axes not retained when using the IMSHOW function?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 22 Gen 2010
Modificato: MathWorks Support Team
il 3 Ago 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
Risposta accettata
MathWorks Support Team
il 3 Ago 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!