Tag of one of the axes erased after reopening GUIDE project.

조회 수: 1 (최근 30일)
Dani Tormo
Dani Tormo 2012년 12월 3일
댓글: Guy Starbuck 2017년 2월 16일
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!

답변 (3개)

Jan
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
Dani Tormo
Dani Tormo 2012년 12월 4일
Setting the NextPlot to add didn't work. I only set this image once at the program start.
I don't really know what's going on. Today I opened the GUI and there were no tag but I run the GUI and the image was shown. Then I put the tag correctly and the image is not shown anymore until I click on the axes to open the callback CreateFcn. Then It charges the image correctly again.
I don't know why but the Tag is erased every time I close the GUI. When I am working on it everything works fine.
Thanks for your help!
Guy Starbuck
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
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
Dani Tormo
Dani Tormo 2012년 12월 3일
Yes, the tag stills there until I restart matlab. I tried to delete this axes and put another with different name but does the same.
Is the right place to set the image at the creation of the axes? Maybe is something wrong with that.
Walter Roberson
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)

댓글을 달려면 로그인하십시오.


Dani Tormo
Dani Tormo 2012년 12월 10일
I don't know what I did but now I don't have this problem anymore. Probably because I erased some callback functions of this axis that were empty and some others of the main figure.
Thanks for your answers anyway!

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by