Editing label, font size and TextInterpreter in already existing figures (.fig files).

조회 수: 12 (최근 30일)
Hi, I have a bunch of .fig files (about 20+), and I don't have access to their codes. I want to change the default fontsize of everything to 16, and change the defaultTextInterpreter to Latex for all the figures. Currently I am doing all of this manually i.e. opening figures in matlab figure viewer and then changing the properties with the GUI, this is obviously very time consuming, so I was wondering if there's a way to write matlab code that can open these fig files, and then change those required properties for all the files. Was thinking about something like this.
d = dir("*.fig"); % all fig files are in current directory
for i=1:length(d)
hf = openfig(d(i).name);
% No idea what to add here to make changes
savefig();
end

답변 (1개)

Ayush
Ayush 2023년 8월 31일
Hi Abdul,
I understand that you would like a way to edit all the figures in your directory. Specifically, you want to edit the label, font size and text interpreter.
It can be done in the following manner (in continuation to the code snippet already provided by you):
1. Inside the for loop, after opening the specific .fig file by its name, get the figure handle by the gcf function. You can refer to the below documentation to know more about the “gcf” function:
2. After getting the figure handle, use it to find the specific object type using the findobj function to edit its specific properties. You can refer to the below documentation to know more about the “findobj” function:
Here is a sample code for reference:
a = findobj(h, 'Type', 'axes')
3. For your use case you would want to edit axes and text properties of the figure.
4. After getting the handle of the required object use the “set” function to assign a value to the desired property. You can refer to the below documentation to know more about the “set” function:
Hope this helps,
Regards,
Ayush Misra

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by