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
0 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!