matlab三条阶梯曲线,matlab 不同的画图(3)

Y=[1 2 5 3.3 0.9 5.2];

names={'一队' '二队' '三队' '四队' '五队' '六队'};

X=[1 2 3 4 5 6];

subplot(211)

pareto(Y,names)%x轴的下标标识为names

title('排列图示例一')

subplot(212)

pareto(Y,X)

title('排列图示例二')%x轴下标有x指定

运行结果: (y轴左侧是标注累积曲线的 )

pareto(Y) labels

each bar with its element index in Y and also plots a line

displaying the cumulative sum of Y.

用stem,stem3绘制柄状图

用stem绘图程序:

二维柄状图

y=linspace(0,2*pi,10)

stem(cos(y),'fill','-.')%对离散图的末端进行了填充

title('二维柄状图示例');

运行结果:

a4c26d1e5885305701be709a3d33442f.png

阶梯图的绘制

绘图函数stairs

使用stairs指令,可画出阶梯图,其精神和柄状图相近,只是将目前资料点的高度向右水平画至下一点为止。

用scatter,scatter3绘制散点图

散点图指令scatter3标志三维数据点,前三个输入宗量必须是同长的向量。

用scatter绘图程序:

二维散点图

x=rand(1,100)*100;%绘制图标的x,y轴的坐标

y=rand(1,100)*100;

s=rand(1,100)*100;%绘制图标的大小

c=rand(1,100)*255;%绘制图标的颜色

subplot(2,1,1)

scatter(x,y);%绘制具有默认大小与颜色的二维散点图

title('二维散点图指令scatter(x,y)');

subplot(2,1,2)

scatter(x,y,s,c);%绘制由参数s、c定义的二维散点图

title('二维散点图指令scatter(x,y,s,c)');

a4c26d1e5885305701be709a3d33442f.png

scatter(X,Y,S,C) displays colored circles at the

locations specified by the vectors X and Y (which

must be the same size).

S determines the area of each marker (specified in

points^2). S can be a vector the same length as

X and Y or a scalar. If S is a scalar,

MATLAB draws all the markers the same size. If S is empty,

the default size is used.

C determines the color of each marker. When C

is a vector the same length as X and Y, the

values in C are linearly mapped to the colors in the

current colormap. When C is a 1-by-3 matrix, it specifies

the colors of the markers as RGB values. If you have 3 points in

the scatter plot and wish to have the colors be indices into the

colormap, C should be a 3-by-1 matrix. C can also

be a color string (see ColorSpec for a list of color string specifiers).

[x,y,z]=sphere(16);%获取球体的坐标

X=x(:);

Y=y(:);

Z=z(:);%矩阵的转换

S=floor((abs(Z)+1)*50);

C=floor(abs(Z)*255);%定义图标大小和颜色与球体的纬度有关

scatter3(X,Y,Z,S,C,'filled')%绘制三维散点图,填充图标

title('三维散点图:球体示例')

a4c26d1e5885305701be709a3d33442f.png

B = floor(A) rounds the elements of

A to the nearest integers less than or equal to

A. For complex A, the imaginary and real parts

are rounded independently.

用plotmatrix绘制矩阵的散点图

指令 plotmatrix 有两种基本调用方式:

(1)对于数据矩阵p*n 维的 X 和p*m 维的 Y ,调用格式 plotmatrix(X,Y) 将画出一个分割成m*n

个子散点图。其中第(i,j) 个子散点图是根据 Y 第i 列和 X 第j 列数据画出的。(2)对于数据矩阵 p*n维的 X ,调用格式

plotmatrix(X) 将画出分割成n*n 个子块的图。该图的对角块,画出的是 X

每列的数据的频数直方图;而其他子块是相应列构成的散点图。该指令可用来观察数据矩阵(或同一矩阵列向量)间的统计关系。

x=randn(50,3);

y=x*[-1 2 1;2 0 1;1 -2 3];%定义绘制矩阵值

plotmatrix(y,'*b')

title('绘制3×3散点图矩阵')

a4c26d1e5885305701be709a3d33442f.png

plotmatrix(X,Y) scatter plots the columns of X

against the columns of Y. If X is p-by-m and Y is p-by-n, plotmatrix produces an

n-by-m matrix of axes.

plotmatrix(X) is the same as plotmatrix(X,X),

except that the diagonal is replaced by hist(X(:,i)).

contour(Z):绘制矩阵Z的等高线图,其中Z为相对X-Y平面的高度,Z必须是至少2*2的矩阵且其中至少有两个不同的值。等高线的级数和各级等高线的数值是基于Z的最大和最小值之间自动选取的,X和Y的范围分别是[1:n]和[1:m],

其中[m,n] = size(Z)。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值