How to select specific figure and specific axes for plot?
Show older comments
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 :-)
Answers (2)
Heiko
on 20 Mar 2023
1 vote
Antoni Garcia-Herreros
on 17 Mar 2023
Hello Heiko,
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!
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!