如果有许多类型的数据,MATLAB提供的颜色就不够了。 这里有一个MATLAB示例,可以自定义线条颜色并放置不同的图例
clear clc; 关闭全部; x=[1、2、3、4、5、6、7、8、9、10、11、12、13、14、15、16、17、18、19、20、21]; y1=rand (1,21 ); y2=rand (1,21 ); y3=rand (1,21 ); y4=rand (1,21 ); y5=rand (1,21 ); y6=rand (1,21 ); y7=rand (1,21 ); y8=rand (1,21 ); 图形; y=[y1; y2; y3; y4; y5; y6; y7; y8 ); markertype=['h '、' o '、' x '、' d '、' s '、'、' * '、' p']; %标记的形状color=[ 0,0,1 ]; [ 0,1,0 ] [ 1,0,0 ] [ 0,1,1 ] [ 1,0,1,0 ] [ 0,0,0 ] [ 0.6,0.2,1 ]; %线的颜色legendtxt={'A '、' b '、' c '、' d '、' e '、' f '、' g '、' proposed'}; 保持接通; forI=1:8plot(x,y(I, )、' color ',color ) I, )、' Marker ',markertype(i ) I ); end%plot(x,y1,' h ',' Color ',[0 0 1]; %scatter(tshort,marker ) :I ),markertype ) ),' MarkerEdgeColor ',color{i} ); legend(legendtxt,' location ',' EastOutside ' );