Tag of one of the axes erased after reopening GUIDE project.
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a problem and I don't know where it comes from.
I have a GUI with four axes. One of these I use it to show a PNG image on the create function:
function circuit_CreateFcn(hObject, eventdata, handles)
imatge=imread('altres\base circuit reduit.png');
image(imatge);
axis off;
The problem is that every time I close Matlab and open the GUI again, the Tag of the axes (circuit) is empty.
Why is happening this?
Thanks!
0 个评论
回答(3 个)
Jan
2012-12-3
编辑:Jan
2012-12-3
Does the image() command clear the tag?
axesH = gca; % Not safe! Better get the handle explicitly!
imatge = imread('altres\base circuit reduit.png');
disp(get(axesH, 'Tag'));
image(imatge);
disp(get(axesH, 'Tag'));
axis off;
If so, set the 'NextPlot' property of the axes object to "add" instead of "replace" before calling image(). Or store the tag and restore it afterwards:
bakTag = get(axesH, 'Tag');
image(imatge);
set(axesH, 'Tag', bakTag);
I cannot test this currently. Clearing the axes' properties happens for other high-level functions as imshow and plot, but not for low-level functions as line.
2 个评论
Guy Starbuck
2017-2-16
This fixed my problem, the tag on the axes was getting stomped when I loaded it. I can't imagine why this is the default behavior. Thanks for the help as always!
Walter Roberson
2012-12-3
If you go into GUIDE and add the tag back in, and save the result, then afterwards if you load just the .fig file, is the tag still there? And does that tag persist when you run the GUI ?
That is, something in the initialization of the GUI might be clearing the axes. clearing an axes removes its tag.
2 个评论
Walter Roberson
2012-12-3
If you save the version with the tag in GUIDE, and quit MATLAB and then openfig() the .fig file, is the tag still there?
My suspicion is that something that happens before that point in the code is clearing the axes in the form you need it.
I can't really advise on whether that is a good place to set the image when using GUIDE, as I don't use GUIDE (too unpredictable for more complex work, too hard to do good dynamic layouts)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!