I have array of points in MATLAB , and i want to draw them all in the same color but with different degree, so the first point will be dark blue and then the second point must be lighter than the first point and so on.
example:
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
can i do that in MATLAB with a large size arrays ??
Thanks,
Use a scatter plot with color arguments and a colormap:
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);

or if it becomes too slow, you can try this alternative: matlab: scatter plots with high number of datapoints
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With