在matlab中画频数图和累积频率图
[a,R]=geotiffread('E:\线性回归00-19趋势值_检验.tif');%读取信息
[m,n]=size(a);
data=a;
data=data*10;%10年趋势变化
data=reshape(data,m*n,1);
data=data(~isnan(data));%把非空数值提取出来
%%双坐标轴
h1=histogram(data,'FaceColor','b')%频数图
set(gca,'XLim', [-0.2 0.2])
set(gca,'YLim', [0 100000])
set(gca,'XTick', [-0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2])
set(gca,'xticklabel',{'-0.2','-0.15','-0.1','-0.05','0','0.05','0.1','0.15','0.2'})
set(gca,'YTick',0:20000:100000)
set(gca,'Yticklabel',{'0','2','4','6','8','10'})
oldLabels = str2num(char(get(gca,'YTickLabel')));
Yscale = 10^4;
newLabels = num2str(oldLabels*Yscale);
set(gca,'YTickLabel',newLabels,'YTickLabelMode','auto');
set(gca,'FontSize',13)
xlabel('NDVI变化趋势 10a^-^1');
ylabel('频数');
hold on
[y1,x1]= ksdensity(data,'function','cdf','npoints',1000);
%[y1,x1] = ksdensity(data,'function','cdf');
ax=plotyy(0,0,x1,y1);
set(get(ax(2),'Ylabel'),'String','累积概率','fontsize',13);