📄 bigfig.m
字号:
function bigfig(fs,lw,ms);
% BIGFIG (ver 2.2c) Set size of appropriate objects in the current figure
%
% bigfig(m) m times larger than nominal
% bigfig(fs,lw,ms) fontsize=fs, linewidth=lw, markersize=ms
% nominal: fs=10, lw=0.5, ms=6
%
% Objects affected: figure,axes,text,line,surface,patch
% Objects unaffected: uimenu,uicontrol,image,light
% Remark: Use oldbigfig with Matlab-4
% (c) Lennart Andersson 1994-2002
%
% 941011 (1.0) First version
% 941021 (1.1)
% 980120 (2.0) Matlab-5
% 980122 (2.1) Supports all objects. Recursive implementation.
% 980204 (2.2) Supports plots generated by Control System Toolbox
% 981229 (2.2b) Fixed a bug; input argument m<1 didn't work
% 021010 (2.2c) Restore axis unit type to avoid bounding box problem
%
% Remains: Improve position of xlabel,ylabel and maybee title
% Include interior axes size dependance on number of digits and
% XAxisPostion, YAxisPosition
% ------ Default plotting style --------
set(0,'DefaultAxesLineStyleOrder','-|--|:|-.');
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 15 15]);
% ------ Nominal values --------
fs0=16;
lw0=1.5;
ms0=10;
% fs0=10; % Nominal font size
% lw0=0.5; % Nominal line width
% ms0=6; % Nominal marker size
% ------ Selection of sizes --------
if nargin==0, % Nominal values
fs=fs0;
lw=lw0;
ms=ms0;
elseif nargin==1,
m=fs;
fs=fs0*m;
if m>=1, % Nonlinear map of line width
lw=(2*m-1)*lw0;
else
lw=lw0*m;
end
ms=ms0*m;
elseif nargin==2,
ms=ms0*fs/fs0;
end
% ------ Main Program --------
Data.FontSize=fs;
Data.LineWidth=lw;
Data.MarkerSize=ms;
setsize(gcf,Data);
% ------ Subroutine -----
function setsize(c,Data)
% Set the size of an object
Type=get(c,'Type');
switch Type
case 'figure'
cc=get(c,'Children');
for j=1:length(cc);
setsize(cc(j),Data);
end
case 'uimenu'
% Do nothing
case 'uicontrol'
% Do nothing
case 'axes'
% -- Labels and Title --
xc=get(c,'xlabel');
yc=get(c,'ylabel');
zc=get(c,'zlabel');
tc=get(c,'title');
setsize(xc,Data);
setsize(yc,Data);
setsize(zc,Data);
setsize(tc,Data);
% -- Set Size and Position of Interior Part of Axes --
unit = get(c,'Units'); % Store unit type
set(c,'Units','points');
set(c,'fontunits','points');
cPosition=get(c,'position');
cFontSize=get(c,'fontsize');
dfs=(Data.FontSize-cFontSize);
if strcmp('LTIdisplayAxes',get(c,'Tag')), % Special axes construction
x=1;
y=1;
z=0;
t=1;
else
x=~isempty(get(xc,'String'));
y=~isempty(get(yc,'String'));
z=~isempty(get(zc,'String'));
t=~isempty(get(tc,'String'));
end
if ~z, % 2D
cPosition(1)=cPosition(1)+(1+y)*dfs;
cPosition(2)=cPosition(2)+(1+x)*dfs;
cPosition(3)=cPosition(3)-(1.5+y)*dfs;
cPosition(4)=cPosition(4)-(1.5+t+x)*dfs;
else % 3D
cPosition(1)=cPosition(1)+(1+z)*dfs;
cPosition(2)=cPosition(2)+dfs;
cPosition(3)=cPosition(3)-(1.5+z)*dfs;
cPosition(4)=cPosition(4)-(1.5+t)*dfs;
end
set(c,'position',cPosition);
set(c,'fontsize',Data.FontSize);
set(c,'linewidth',Data.LineWidth);
set(c,'Units',unit); % Restore unit for printing purposes
% -- Other Objects in Axes ---
cc=get(c,'Children');
for j=1:length(cc);
setsize(cc(j),Data);
end
case 'text'
set(c,'fontunits','points');
set(c,'fontsize',Data.FontSize);
case 'line'
set(c,'linewidth',Data.LineWidth);
set(c,'markersize',Data.MarkerSize);
case 'surface'
set(c,'linewidth',Data.LineWidth);
set(c,'markersize',Data.MarkerSize);
case 'image'
% Nothing to do
case 'patch'
set(c,'linewidth',Data.LineWidth);
set(c,'markersize',Data.MarkerSize);
case 'light'
% Nothing to do
otherwise,
disp(['Warning: Object of type ' Type ' not supported']);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -