Azzera filtri
Azzera filtri

Assign certain colors to certain dots of a scatter plot

1 visualizzazione (ultimi 30 giorni)
Hey y'all,
I need to assign certain colors to certain dots of a scatter plot. I've written something like this:
Color = zeros(size(Check,1),1);
for i = 1:size(Check,1)
if Check(i) == 0
Color(i) = [0.3010 0.7450 0.9330];
elseif Check(i) == 1
Color(i) = [0.4660 0.6740 0.1880];
elseif Check(i) == 2
Color(i) = [0.9290 0.6940 0.1250];
elseif Check(i) == 3
Color(i) = [0.8500 0.3250 0.0980];
elseif Check(i) == 4
Color(i) = [0.6350 0.0780 0.1840];
end
end
scatter(x,y,Color,'filled','s');
Beware that 'x', 'y', 'Color' and 'Check' have the same dimension (15000 x 1). Numbers in 'Check' are either '0', '1', '2', '3', or '4'. I just need to assign five different colors to my scatter plot based on the numbers I have in 'Check' matrix. The colors should be those that I used in the code as I need this plot to match with another bar chart I already have. Any help will be highly appreciated!

Risposte (0)

Categorie

Scopri di più su Graphics Objects in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by