运行 绘图脚本时如何关闭图形显示
How to turn off figure display while running plot scripts
我创建了几个条形图和散点图脚本来绘制我的数据。问题是 Matlab 在创建绘图时显示每个绘图,使事情变得非常具有破坏性(在绘图完成之前我不能做任何其他事情)。我已经尝试了在 Mathworks.com 和 here on Stack Exchange 上发布的几种方法,但其中 none 有效。这是我的散点代码示例:
fig = figure(456);
scatter(Data(:,1),Data(:,2),'filled');
hold on;
h = plot(Data(:,1),b,'-');
legend(h,sprintf('r = %s, p = %s',num2str(r),num2str(p)));
title(sprintf(<plot title>));
xlabel(sprintf('%s',set1.textdata{1,z+2}));
ylabel(sprintf('%s',set2.textdata{1,f+2}));
hold off
set(findall(fig,'type','text'),'fontSize',16,'fontweight','bold')
saveas(figure(456),fullfile(output_path, sprintf(<filename>));
close(fig)
有人能帮忙吗?非常感谢!
好的,这应该有效:
fig = figure('Visible', 'off');
scatter(Data(:,1),Data(:,2),'filled');
hold on;
h = plot(Data(:,1),b,'-');
legend(h,sprintf('r = %s, p = %s',num2str(r),num2str(p)));
title(sprintf(<plot title>));
xlabel(sprintf('%s',set1.textdata{1,z+2}));
ylabel(sprintf('%s',set2.textdata{1,f+2}));
hold off
set(findall(fig,'type','text'),'fontSize',16,'fontweight','bold')
saveas(fig,fullfile(output_path, sprintf(<filename>));
close(fig)
我创建了几个条形图和散点图脚本来绘制我的数据。问题是 Matlab 在创建绘图时显示每个绘图,使事情变得非常具有破坏性(在绘图完成之前我不能做任何其他事情)。我已经尝试了在 Mathworks.com 和 here on Stack Exchange 上发布的几种方法,但其中 none 有效。这是我的散点代码示例:
fig = figure(456);
scatter(Data(:,1),Data(:,2),'filled');
hold on;
h = plot(Data(:,1),b,'-');
legend(h,sprintf('r = %s, p = %s',num2str(r),num2str(p)));
title(sprintf(<plot title>));
xlabel(sprintf('%s',set1.textdata{1,z+2}));
ylabel(sprintf('%s',set2.textdata{1,f+2}));
hold off
set(findall(fig,'type','text'),'fontSize',16,'fontweight','bold')
saveas(figure(456),fullfile(output_path, sprintf(<filename>));
close(fig)
有人能帮忙吗?非常感谢!
好的,这应该有效:
fig = figure('Visible', 'off');
scatter(Data(:,1),Data(:,2),'filled');
hold on;
h = plot(Data(:,1),b,'-');
legend(h,sprintf('r = %s, p = %s',num2str(r),num2str(p)));
title(sprintf(<plot title>));
xlabel(sprintf('%s',set1.textdata{1,z+2}));
ylabel(sprintf('%s',set2.textdata{1,f+2}));
hold off
set(findall(fig,'type','text'),'fontSize',16,'fontweight','bold')
saveas(fig,fullfile(output_path, sprintf(<filename>));
close(fig)