matlab中 关于scatter plot 函数中颜色的问题
发布网友
发布时间:2022-05-01 23:38
我来回答
共2个回答
热心网友
时间:2022-06-25 04:04
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 length(X)-by-3 matrix, it specifies the colors of the markers as RGB values. C can also be a color string (see ColorSpec for a list of color string specifiers).
上面的是help里面的话,里面说了When C is a length(X)-by-3 matrix,t specifies the colors of the markers as RGB values,也就是后面决定颜色的RGB不能只是一列数组,要是length(X)-by-3 matrix。
scatter(msdata(i,1),msdata(i,2),'.',[0.1,0.3,0]); 可以改成
scatter(msdata(i,1),msdata(i,2),'.',ones(length(msdata(i,1)))*[0.1,0.3,0]);
自己揣摩下试试
热心网友
时间:2022-06-25 04:04
x = rand(1,10)*10;
y = rand(1,10)*10;;
z =rand(1,10)*10;;
t = round(sqrt(z))*35; %控制点大小
c = mod(round(z+2),255)/255; %控制点颜色,c可以是大于0小于1的值,与x同尺寸;可以是M-by-3 matrix(即RGB色彩格式);
scatter(x,y,t,c,'filled');