- 积分
- 1890
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2018-2-27
- 最后登录
- 1970-1-1
|

楼主 |
发表于 2018-3-6 16:18:13
|
显示全部楼层
%z作者的Li_plot函数代码
% Created by LI Xu
% Version 1.0
% Feburary 27, 2016
% Description:
% Plot precipitation
% If you have any question about this code,
% please do not hesitate to contact me via E-mail:
% jeremy456@163.com
% Blog:
% http://blog.sciencenet.cn/u/lixujeremy
% http://lixuworld.blogspot.com/
function LI_plot(years, prec)
clf;
handle=bar(years, prec);
set(gca, 'xlim', [min(years)-1, max(years)+1]);
set(gca, 'fontname', 'Arial', 'fontsize', 15);
set(handle, 'facecolor', [0,1,1]);
set(gcf, 'color', 'w');
set(gca, 'ylim', [600, 1800]);
hold on;
% Trend Line
X=[ones(size(years)), years];
[b, ~, ~, ~, stats]=regress(prec, X);
b1=sprintf('%.3f', b(1));
b2=sprintf('%.3f', b(2));
str1=['{\ity}=', b2, '{\itx}+', b1];
pval=stats(3);
pval=sprintf('%.3f', pval);
str2=['{\itp}=', pval];
instr={str1, str2};
instratts.font='Arial';
instratts.xscale=0.1;
instratts.yscale=0.85;
instratts.fontsize=30;
instratts.interval=0.1;
PlotAddText(gca, instr, instratts);
xlabel('{\itYear/a}', 'fontname', 'Times New Roman', 'fontsize', 20);
ylabel('{\itAnnual Precipitation/mm}', 'fontname', 'Times New Roman', 'fontsize', 20);
xlim=get(gca, 'xlim');
yy=b(1)+b(2)*xlim;
linehand=plot(xlim, yy, 'k-');
set(linehand, 'linewidth', 2);
hold off;
end
|
|