Reputation: 5104
I have figures (in Matlab's fig file format) each of which contains a line plot with two lines (representing EEG curves), axes, bunch of labels etc.
I want to:
I would loop over the fig files and do the same thing for each of them.
Is there a list of all the objects within the figure that I could index and edit? How can I get to those objects using commands (i.e. without the gui)?
Upvotes: 0
Views: 115
Reputation: 2192
Line, lable, etc. are children of axis, which is itself a child of a figure. What you need to do is acquire handles to the objects you want to change through this hierarchy.
% Get a handle to the figure
hfig = openfig('testfig');
% Get all children of the CurrentAxes. Most of what you want is here.
axes_obj = allchild(hfig.CurrentAxes);
% Edit Axes object according to its type
For ii = 1:length(axes_obj)
switch axes_obj(ii).Type
case 'Text'
% Do something, for example:
axes_obj(ii).String = 'changed';
case 'Line'
% Do something, for example:
axes_obj(ii).MarkerEdgeColor = 'b';
end
end
% Save figure
savefig(hfig, 'testfig')
You can see all the properties of the object you wish to edit by simply typing axes_obj(ii)
in the command window.
Upvotes: 3