- 积分
- 10872
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-3-6
- 最后登录
- 1970-1-1
|
发表于 2018-9-6 12:54:35
|
显示全部楼层
歪个楼,再来个自用的函数,关于matlab画图的常规美化设置一个函数搞定。
使用方法:
plot 了之后,在所有语句的最后再打上beautify即可:
clc;
clear all;
x=0.5:0.1:5;
y=cos(x);
figure(1);clf;
plot(x,y,'ko-')
xlim([0 5])
beautify% 因为在这个函数中有关于右侧和上方坐标轴的设置,beautify要放在所有语句(关于左方和下方坐标轴的设置语句)的后面
--------------------分割线------------函数:
function beautify
% function which produces a nice-looking plot and sets up the page for nice printing
set(gca,'LineWidth',1.5);
set(gca,'FontSize',12);
set(gca,'FontWeight','bold');
set(gcf,'color','w');
set(get(gca,'xlabel'),'FontSize', 12, 'FontWeight', 'bold');
set(get(gca,'ylabel'),'FontSize', 12, 'FontWeight', 'bold');
% set(get(gca,'title'),'FontSize', 18, 'FontWeight', 'bold');
% % axis tight;%%limit axis according to the data's limits
% % axis square
set(gca,'tickdir','out')
set(findobj('Type','line'),'LineWidth',1.5);
set(findobj('Type','text'),'fontsize',12);
%
box off
ax2 = axes('Position',get(gca,'Position'),...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none',...
'XColor','k','YColor','k');
set(ax2,'ytick', []);
set(ax2,'xtick', []);
set(gca,'LineWidth',1.2);
% box on
%%print pdf
% % set(gcf,'PaperUnits','inches');
% % set(gcf,'PaperSize', [8 8]);
% % set(gcf,'PaperPosition',[0.5 0.5 7 7]);
% % set(gcf,'PaperPosition Mode','Manual');
|
|