如何将相同的设置应用于matlab中的不同图形?

How to apply same settings to different figures in matlab?

我想将此更改应用于我的所有图形:

set(gcf,'color','w');
box off;
set(gca,'FontSize',13,'fontWeight','bold')
set(findall(gcf,'type','text'),'FontSize',13,'fontWeight','bold')

我该怎么做而不需要像这样重复自己:

figure(1);
set(gcf,'color','w');
figure(2);
set(gcf,'color','w');

如果您只需要一个会话或一个脚本,请将其添加到脚本的顶部(或在绘制任何内容之前在 matlab 命令行中添加):

set(0, 'DefaultFigureColor', 'w');

set(groot, 'DefaultFigureColor', 'w');

这消除了对多个 set 命令的需要。 如果您希望它在每个 matlab 会话中都适用,您应该考虑将其放入您的 startup.m 文件中。类型

which startup

找到您的启动文件或创建一个(如果不存在)。检查 this 您可能想要为其设置默认值的其他属性。