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!