In a m-file, I am plotting 16 different types of plots (not in a loop). Is it possible to set the following properties of all the plots by writing only once:

 set(gca,'linewidth',1,'fontsize',12);
 set([xh, yh, th],'fontsize',12);  
有帮助吗?

解决方案

It turns out that the answer is yes, which can be easily checked e.g. using this code

figure
xh = gca;
figure
yh = gca;

set([xh, yh], 'fontsize', 12, 'linewidth', 1);

Note that the 'linewidth' property of an axes applies to the lines that make up the axes, not to any lines plotted into it. If you want to change their properties, you have to either collect the handles of all the line objects, or search for line objects later using

lh = findobj(0, 'Type', 'line');
set(lh, 'linewidth', 1)

Here '0' refers to the root object, of which all figures are children.

其他提示

You can change default plotting parameters:

set(0,'DefaultLineLineWidth',1);
set(0,'DefaultAxesFontSize', 12);
set(0,'DefaultTextFontSize', 12);

Yes, it is meant to be "LineLine", it's to distinguish it from DefaultPatchLineWidth. Once you change these, it will only affect new figure windows; if you have already created the plots, use the answer given by A. Donda.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top