我在MATLAB中有点数组,我想用相同的颜色绘制它们,但程度不同,所以第一个点将是深蓝色,然后第二个点必须比第一个点浅,依此类推。
例子:
a = [1:100];
plot(a,a,'*');
then point (1,1) will be very dark red ,,, and point (100,100) will be very very light red
我可以在具有大型数组的MATLAB中执行此操作吗?
谢谢,
x = linspace(0,2*pi,100);
y = sin(x);
a = [1:100];
dotsize=25;
clridx = 1:100;
scatter(x,y,dotsize,clridx,'fill');
% create the colormap:
color1=[25 25 112]/255; % Midnight Blue
color2=[135 206 250]/255;% Light Sky Blue
numcolors = numel(clridx);
% create the gradients
clrmap = cell2mat(arrayfun(@(a,b)linspace(a,b,numcolors )',color1,color2,'uni',false));
% set the colormap
colormap(clrmap);
或者它变得太慢,您可以尝试以下替代方法:matlab:散点图具有大量数据点
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句