How to find axes in gui?
6 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm trying to plot sth on axes2 in a gui, I think first I must find the axes2 and then set it as current axes.
But MATLAB could not find axes2, despite it can find all axes objects in figure.
ax=findobj(gcf,'Tag','axes2')
axes(ax);
What can be the problem?
rft
3 个评论
回答(2 个)
matt dash
2014-12-17
Certain plotting functions, including cla, can reset the axes's tag. As Ben11 says, the better option is to store the handle somewhere permanent (i.e. in the handles structure, which if you're using GUIDE happens automatically) and access it from there.
If you need to rely on findobj, you need to be careful that you don't use any functions that would reset the properties you're using to test with findobj.
Ahmed Maalej
2019-5-2
编辑:Ahmed Maalej
2019-5-2
I faced the same problem trying to actualise the resulting image after parameter changes. In my case I used more than one figure, and I wanted to display the result on axes of my last figure after a pushbutton:
ok_mask_button= uicontrol(handles.pan,'Style','pushbutton','Units', 'normal', 'Position',[.55 .9 .08 .06],'FontSize',12,'FontWeight','bold', 'String','Ok','Callback', @Mask_parameters);
So to display the image using my callback function, the solution was :
% some code above%
...
ax = gca;
imshow(handles.mask,'Parent',ax)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!