MATLAB: Scatter Plot and Conditional Colour Gradients.

color gradientscatter plot

f_tot = rand(50,9);
hold on
box on
for ph = 1:length(numhels)
for pr = 1: 1:Nrows(1)
if f_tot(ph,pr) >= 0.85000
c = 'red';
scatter(x(ph,pr),y(ph,pr),9,c,'filled');
hold on;
else
if f_tot(ph,pr) >= 0.7 && f_tot(ph,pr) <= 0.84999
c = 'yellow';
scatter(x(ph,pr),y(ph,pr),9,c,'filled');
hold on;
else
if f_tot(ph,pr) >= 0.6 && f_tot(ph,pr) <= 0.69999
c = 'green';
scatter(x(ph,pr),y(ph,pr),9,c,'filled');
hold on;
else
if f_tot(ph,pr) >= 0.4 && f_tot(ph,pr) <= 0.59999
c = 'cyan';
scatter(x(ph,pr),y(ph,pr),9,c,'filled');
hold on;
else
if f_tot(ph,pr) < 0.40
c = 'blue';
scatter(x(ph,pr),y(ph,pr),9,c,'filled');
hold on;
end
end
end
end
end
end
end
Hello,
Can the scatter plot be made to take in the colormap or jet function.Instead of the 'c'defining specific colors but rather have the entire points in the plot as a gradient.
Thanks

Best Answer

No loops:
scatter(x(:), y(:), 9, f_tot(:), 'filled');
colormap(jet)
Related Question