2024年6月12日发(作者:母邦)
Matlab画图设置线宽和字号
Matlab画图设置线宽和字号
既然这么多人来这里看过,我就多做点注释,方便大家参考。
下边这段代码不需要特别设置,只需要在plot语句之后插入即可。
%plot your figure before
%%%%%%%%%%%%%%%%%%%%%
图片大小为7cm×5cm
set(gcf,'Units','centimeters','Position',[10 10 7 5]);%设置
%get hanlde to current axis返回当前图形的当前坐标轴的句柄,
%(the first element is the relative distance of the axes to the
left edge of the figure,...
width and height;
比例
5号
%the second the vertical distance from the bottom, and then the
set(gca,'Position',[.13 .17 .80 .74]);%设置xy轴在图片中占的
set(get(gca,'XLabel'),'FontSize',8);%图上文字为8 point或小
set(get(gca,'YLabel'),'FontSize',8);
set(get(gca,'TITLE'),'FontSize',8);
set(gca,'fontsize',8);
set(gca,'linewidth',0.5); %坐标线粗0.5磅
area
磅
set(gca,'box','off');%Controls the box around the plotting
set(get(gca,'Children'),'linewidth',1.5);%设置图中线宽1.5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
下边附上其他参数的设置方法,其实就是利用函数句柄来对图形进行
操作。有兴趣的自己研究研究:
Here are some tips on making "better" figures with Matlab for
theses, papers/abstracts, and reports. Basically, you need to
change/disable some of Matlab's default settings to get the
print you want.
Figures and axes/subplots are defined in Matlab by a set of
"handles" that, for example, define the size of a figure or the
position of an axes system within a figure. To understand how
this work you must know that Matlab is written object oriented.
The way I understand is that there is a hierachie in the
different objects. For example, your screen has the highest
priority as it defines the maximum size a (usable) figure can
have. The next lower member is the figure. If you change a figure
size, the screen won't be affected, but if you could shrink the
screen size, the figure size would be changed as well. Next
comes the axes system(s) in the figure. The size and position
of the axes system depends on the figure. For example, if you
shrink the size of the figure, the size of your plot will change
accordingly. On the other hand, if you change the size of a
subplot/axes, the figure will not change. The object oriented
guys call this parents (higher ranking in the hierachy) and
children thing.
In Germany, we have the saying that trying is more worth and
studying or practise makes the master. Therefore, I recommend
that you play with these options to see how they change the
appearence of your figure plot, ...
I'll start first with a list ofparameters that you can use to
modify a matlab plot and then go intomore details later. Start
with the following commands to create a lineplot:
2024年6月12日发(作者:母邦)
Matlab画图设置线宽和字号
Matlab画图设置线宽和字号
既然这么多人来这里看过,我就多做点注释,方便大家参考。
下边这段代码不需要特别设置,只需要在plot语句之后插入即可。
%plot your figure before
%%%%%%%%%%%%%%%%%%%%%
图片大小为7cm×5cm
set(gcf,'Units','centimeters','Position',[10 10 7 5]);%设置
%get hanlde to current axis返回当前图形的当前坐标轴的句柄,
%(the first element is the relative distance of the axes to the
left edge of the figure,...
width and height;
比例
5号
%the second the vertical distance from the bottom, and then the
set(gca,'Position',[.13 .17 .80 .74]);%设置xy轴在图片中占的
set(get(gca,'XLabel'),'FontSize',8);%图上文字为8 point或小
set(get(gca,'YLabel'),'FontSize',8);
set(get(gca,'TITLE'),'FontSize',8);
set(gca,'fontsize',8);
set(gca,'linewidth',0.5); %坐标线粗0.5磅
area
磅
set(gca,'box','off');%Controls the box around the plotting
set(get(gca,'Children'),'linewidth',1.5);%设置图中线宽1.5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
下边附上其他参数的设置方法,其实就是利用函数句柄来对图形进行
操作。有兴趣的自己研究研究:
Here are some tips on making "better" figures with Matlab for
theses, papers/abstracts, and reports. Basically, you need to
change/disable some of Matlab's default settings to get the
print you want.
Figures and axes/subplots are defined in Matlab by a set of
"handles" that, for example, define the size of a figure or the
position of an axes system within a figure. To understand how
this work you must know that Matlab is written object oriented.
The way I understand is that there is a hierachie in the
different objects. For example, your screen has the highest
priority as it defines the maximum size a (usable) figure can
have. The next lower member is the figure. If you change a figure
size, the screen won't be affected, but if you could shrink the
screen size, the figure size would be changed as well. Next
comes the axes system(s) in the figure. The size and position
of the axes system depends on the figure. For example, if you
shrink the size of the figure, the size of your plot will change
accordingly. On the other hand, if you change the size of a
subplot/axes, the figure will not change. The object oriented
guys call this parents (higher ranking in the hierachy) and
children thing.
In Germany, we have the saying that trying is more worth and
studying or practise makes the master. Therefore, I recommend
that you play with these options to see how they change the
appearence of your figure plot, ...
I'll start first with a list ofparameters that you can use to
modify a matlab plot and then go intomore details later. Start
with the following commands to create a lineplot: