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

Ben11
Ben11 2014년 12월 17일
편집: Ben11 2014년 12월 17일
If axes2 is stored in the handles structure, you can directly use
axes(handles.axes2)
Is it the case? As for the cause of your problem, maybe you have more than 1 figure opened and the current figure is not the one containing axes2?
Rafet
Rafet 2014년 12월 17일
Yes, I have two figures opened, but the one including axes2 is the last opened and I assume it is the current figure.
Besides, MATLAB can find all axes in figure with
findall('type','axes')
command, but cannot find axes separately.
By the way I solved the issue by assingning axes handles to global variables.
thanks
muhammad zulhelmy
muhammad zulhelmy 2017년 3월 5일
how can i copy data from axes2, then display to axes3 ??

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

답변 (2개)

matt dash
matt dash 2014년 12월 17일

0 개 추천

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.

댓글 수: 1

Rafet
Rafet 2014년 12월 17일
I'll keep this in mind.
thanks matt

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

Ahmed Maalej
Ahmed Maalej 2019년 5월 2일
편집: Ahmed Maalej 2019년 5월 2일

0 개 추천

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)
I needed to use gca to specify that I wanted to work on the current axes.

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2014년 12월 17일

편집:

2019년 5월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by