加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

[转载]matlab的scatterhist 用法--将散点图和直方图结合!

(2015-04-21 08:40:38)
标签:

转载

分类: MATLAB

scatter用来画散点图,而hist系列的函数是用来画直方图,具体应用可以在官网上找到。

要想把散点图和直方图结合起来,可以用scatterhist函数。

具体用法见官网:http://www.mathworks.cn/help/toolbox/stats/scatterhist.html

其中,用法如下:

scatterhist(x,y)
h = scatterhist(...)
scatterhist(...,'param1',val1,'param2',val2,...)
注意:x和y必须所含元素个数相同,即维数相同

 

参数可以有以下三种:

  • 'NBins' — A scalar or a two-element vector specifying the number of bins for the X and Y histograms. The default is to compute the number of bins using Scott's rule based on the sample standard deviation.

  • 'Location' — A string controlling the location of the marginal histograms within the figure. 'SouthWest' (the default) plots the histograms below and to the left of the scatterplot, 'SouthEast' plots them below and to the right, 'NorthEast' above and to the right, and 'NorthWest' above and to the left.

  • 'Direction' — A string controlling the directation of the marginal histograms in the figure. 'in' (the default) plots the histograms with bars directed in towards the scatterplot, 'out' plots the histograms with bars directed out away from the scatterplot.

NBins就是指直方图的单位间隔,默认间隔是标准差

Location是指直方图位于散点图的那个位置,默认是西南,意思是在左侧和下方。

Direction是指直方图的朝向,默认是“in”即朝向散点图,而out是朝外。

如下图几个例子:

Example 1

Independent normal and lognormal random samples:

x = randn(1000,1);
y = exp(.5*randn(1000,1));
scatterhist(x,y)

http://www.mathworks.cn/help/toolbox/stats/scatterhist1.png用法--将散点图和直方图结合!" />

Example 2

Marginal uniform samples that are not independent:

u = copularnd('Gaussian',.8,1000);
scatterhist(u(:,1),u(:,2),'Direction','out')

http://www.mathworks.cn/help/toolbox/stats/scatterhist2.gif用法--将散点图和直方图结合!" />

Example 3

Mixed discrete and continuous data:

load('carsmall');
scatterhist(Weight,Cylinders,'NBins',[10 3],'Direction','out')

http://www.mathworks.cn/help/toolbox/stats/scatterhist3.gif用法--将散点图和直方图结合!" />

0

  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有