||
直方图上显示数值
close all ,
x = rand(100,1);
%获得直方图的数据
[n,y] = hist(x);
maxN = max(n);
%设置显示x,y长度限制
axis([0 1.2 0 maxN+2])
%根据直方图的数据绘制出图形
bar(y,n);
for i = 1:length(y)
%直方图上面数据对不齐,利用水平和垂直对齐 ,可以参考search Document 中的text函数
text(y(i),n(i)+0.5,num2str(n(i)),'VerticalAlignment','middle','HorizontalAlignment','center');
end
histfit(x,maxN)显示拟合的曲线%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
[f,xi,bw] = ksdensity(x);%核密度估计的方法
figure()
plot(xi,f,'-k','LineWidth',2);hold on
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=normrnd(0,1,1,100);
hist(x);
[n,hx]=hist(x);
str = mat2cell(num2str(n'));
text(hx,n+0.3,str,'Color','r');
x=[1 2 ];
y=[0. 12];
%y=exp(-x.*x);
% stem(x,y,'r');
bar(x,y,'b');
for ii=1:length(x)
str=sprintf('%4.1f%%',y(ii)*100);%显示百分号
%text(x(ii)-0.2,y(ii)+0.02,str);
text(x(ii)-0.2,y(ii)+0.02,str,'VerticalAlignment','middle','HorizontalAlignment','center');
end
% set(gca,'FontName','Times New Roman','FontSize',15);
直方图拟合
http://www.ilovematlab.cn/thread-77204-1-1.html
x=[1 2 3 4 5 6];
y=[2 4 6 8 10 12];
bar(x,y,'b');hold on;
x2=min(x):(length(x)-1)/6:max(x)%点列
y2=interp1(x,y,x2,'spline')%上述函数进行插值,
% figure,
plot(x2,y2,'r','Linewidth',2);做出图像.
基于Matlab的制作箭头图[by Fantuanxiaot]
http://www.matlabsky.com/thread-92716-1-1.html
彩色柱子,或者每一个柱的颜色不一样
matlab程序,修改一下文年后缀即可。
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-26 23:46
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社