1.1二维散点图
scatter函数
例一:
x=[12,14,16,21,23,25,27,19,23,21]
y=[78,79,69,74,71,82,68,85,83,81]
scatter(x,y,'r','g')
输出图像:
例二:绘制散点图的子图
x=linspace(-2,2,100)
y=x.^2
ax1=subplot(2,1,2)
scatter(ax1,x,y)
输出图像:
1.2gscatter函数
使用说明:
gscatter(x,y,group)
gscatter(x,y,group,clr,sym,siz)
gscatter(x,y,group,clr,sym,siz,doleg)
gscatter(x,y,group,clr,sym,siz,doleg,xnam,ynam)
h = gscatter(…)
例一:
A=magic(6)
group=[2,3,4,5,1,7]
gscatter(A(:,1),A(:,2),group)
得出图像:
1.3scatter3函数
例:
x=[11,12,14,16,17,21,23,22,25,18,19,16]
y=[33,35,36,41,42,44,39,38,37,39,44,42]
z=[90,98,99,89,91,92,93,94,95,91,88,87]
scatter3(x,y,z)
例二:三维离散点图
N=5000
x=rand(1,N)
y=rand(1,N)
z=rand(1,N)
scatter3(x,y,z,100,z,'.')
colorbar
得出图像: