funykatebird的个人博客分享 http://blog.sciencenet.cn/u/funykatebird

博文

matlab 绘制直方图——常用命令

已有 7235 次阅读 2017-2-27 20:48 |个人分类:论文写作|系统分类:论文交流

直方图上显示数值

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程序,修改一下文年后缀即可。

ColorBars.txt




https://blog.sciencenet.cn/blog-597740-1036452.html

上一篇:支持向量机资料汇总
下一篇:visio转eps问题
收藏 IP: 202.113.11.*| 热度|

1 杨正瓴

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-12-26 23:27

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部