- 积分
- 26283
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-6-1
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 kongfeng0824 于 2013-7-28 14:24 编辑
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 1Independent normal and lognormal random samples:
x = randn(1000,1);y = exp(.5*randn(1000,1));scatterhist(x,y)
Example 2Marginal uniform samples that are not independent:
u = copularnd('Gaussian',.8,1000);scatterhist(u(:,1),u(:,2),'Direction','out')
Example 3Mixed discrete and continuous data:
load('carsmall');scatterhist(Weight,Cylinders,'NBins',[10 3],'Direction','out')
|
|