- 积分
- 1910
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2018-2-27
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
% Created by Han yuyang
% version 1.0
% March 8,2018
% Description:
% Plot precipitation
% liner regress to show the tendency(not very useful)
% note:
% If you have any question about this code,
% please do not hesitate to contact me via E-mail:
% fadedflowers#foxmail.com
function han_plot(years,prec)
figure;
handle=bar(years,prec);
set(gca, 'xlim', [min(years)-1, max(years)+1],'ylim',[600,1800]);
xlabel('{\itYear/a}', 'fontname', 'Times New Roman', 'fontsize', 20);
ylabel('{\itAnnual Precipitation/mm}', 'fontname', 'Times New Roman', 'fontsize', 20);
set(gcf,'outerposition',get(0,'screensize'));
set(handle,'facecolor',[0,255,255]./255);
%change the color of the bar to Cyan
hold on
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.05;
instratts.yscale=0.95;
instratts.fontsize=0.015;
instratts.interval=0.05;
% see note in PlotaddText
PlotaddText(gca, instr, instratts);
yy=b(1)+b(2)*xlim;
linehand=plot(xlim, yy, 'k-');
set(linehand, 'linewidth', 2);
hold off;
end
% instr is a cell contain the text
PlotAddText(gca, instr, instratts);
yy=b(1)+b(2)*xlim;
linehand=plot(xlim, yy, 'k-');
set(linehand, 'linewidth', 2);
hold off;
end
|
|