Matlab画直⽅图
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20%% 绘制统计直⽅图
%hist(y):如果y是向量,则把其中元素放⼊10个条⽬中,且返回每条中的元素的个数;如果y为矩阵,则分别对每列进⾏处理,显⽰多组条形。
%[n,xout]=hist(y,x):⾮递减向量x的指定bin的中⼼。向量xout包含频率计数与条⽬的位置。
x=-10:.1:10;
y1=randn(2008,1);
y2=randn(2008,3);
孩子玩具figure;
colormap(winter);
subplot(2,2,1);
hist(y1);%把其中元素放⼊10个条⽬中
title('y1为向量,default,n=10');
subplot(2,2,2);
hist(y2);%分别对每列进⾏处理,显⽰多组条形
title('y2为矩阵');
subplot(2,2,3);
hist(y1,x);%⽤户也可以使⽤[n,xout]=hist(y1,x);bar(xout,n)绘制条形直⽅图
title('向量x指定条⽬');
subplot(2,2,4);
hist(y2,1000);%第⼆个参数为标量时指定bin的数⽬
title('nbins=1000');
1 2 3 4 5 6 7 8新居昭乃
9%% ========均值⽅差直⽅图========
a=[8910789];%mean
b=[111111];%std
figure();
h=bar(a);
ch=get(h,'children');
t(ch,'FaceVertexCData',[4;2;3;1;5;6]);%使⽤Indexed形式指定每组bar的颜⾊hold on;
含水
errorbar(a,b,'k','LineStyle','none');
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24%% =======散点图scatter , scatter3 , plotmatrix======
%scatter3(X,Y,Z,S,C):在由向量X、Y和Z指定的位置显⽰⼤⼩和颜⾊分别由S和C决定的离散点figure;
[x,y,z] = sphere(16);
X = [x(:)*.5x(:)*.75x(:)];什么是家政服务
Y = [y(:)*.5y(:)*.75y(:)];
巧克力怎么做的Z = [z(:)*.5z(:)*.75z(:)];
S = repmat([1025]*10,numel(x),1);
C = repmat([123],numel(x),1);
蛋糕店有哪些品牌subplot(1,2,1);
scatter(X(:),Y(:),S(:),C(:));
title('scatter');
中国福字
subplot(1,2,2);
scatter3(X(:),Y(:),Z(:),S(:),C(:),'filled'), view(-60,60);
title('scatter3');
%plotmatrix(X,Y)绘出X(p*M)与Y(p*N)的列组成的散度图(N,M)
鼓的造句figure;
X=randn(100,2);Y=randn(100,2);
subplot(1,3,1),plotmatrix(X);%等价于plotmatrix(X,X),除了对⾓上的图为X每⼀列的直⽅图hist(X(:,col)) title('plotmatrix(X)');
subplot(1,3,2),plotmatrix(X,X);
title('plotmatrix(X,X)');
subplot(1,3,3),plotmatrix(X,Y);
title('plotmatrix(X,Y)');