作业帮 > 综合 > 作业

matlab中 关于scatter plot 函数中颜色的问题

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/04 02:29:17
matlab中 关于scatter plot 函数中颜色的问题
“帮助”中说scatter的颜色只有若干种(没弄错的化是8种不同颜色可用)
比如:
scatter(msdata(i,1),msdata(i,2),'.','y');
scatter(msdata(i,1),msdata(i,2),'.','g');
scatter(msdata(i,1),msdata(i,2),'.','w');
……
……
如果要用比较多的颜色来表示画出的点,用上述8种颜色俨然不够了
请问,这里的'y’,'g’等能否用一个RGB值来表示呢,
我试过比如scatter(msdata(i,1),msdata(i,2),'.',[0.1,0.3,0]); 这样貌似不行啊,
还有其他方法吗
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]);
自己揣摩下试试