How to select specific figure and specific axes for plot?

조회 수: 131 (최근 30일)
Heiko
Heiko 2023년 3월 17일
답변: Heiko 2023년 3월 20일
Hi,
i have a code running where you can open a figure (here: animation.fig), which has been pre-created with guide.
this figure contains static-text and 2 axes.
How can i select in which figure and in which axes of this figure i want to draw my plot??
I've been searching for a lot of time, but can't get it working.
I tried of course
figure(animation); % open figure and set to active
ax = findobj(animation, 'Type', 'Axes'); % get all axes in this figure (works! Here: axes2 and axes3)
axes(handles.axes2); <-- doesn't work: "Unrecognized field name "axes2"
Please help :-)

답변 (2개)

Heiko
Heiko 2023년 3월 20일
Hi Antoni,
thank you so much!!
What i think i have learned:
animation=openfig('animation.fig'); % not only just opening but defining an 'object' being the actual parent
NAxes=animation.Children; % here i learnend about correct use of children/ parent settings
a1=NAxes(1); % within NAxes() are all 'children' of the current parent figure. Might be static text, axes...
plot(YourData,'Parent',a1) % Plot/ write data in current parent and in children a1 as declared the line above
Heiko :)

Antoni Garcia-Herreros
Antoni Garcia-Herreros 2023년 3월 17일
Hello Heiko,
You can take a look here.
You could try something like this:
% Let's say your figure has been saves as a .fig file
animation=openfig('animation.fig');
NAxes=animation.Children;
a1=NAxes(1); % Chose your depending on where you want to plot your data (1 or 2)
hold(a1,'on') % If there is data already in the plot you may want to hold it
plot(YourData,'Parent',a1) % Plot data on ax1
I hope this helps!

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by