Borrar filtros
Borrar filtros

Assign certain colors to certain dots of a scatter plot

1 visualización (últimos 30 días)
Antonio
Antonio el 20 de Abr. de 2017
Editada: Antonio el 21 de Abr. de 2017
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!
  1 comentario
Image Analyst
Image Analyst el 20 de Abr. de 2017
You're welcome! That was easy - I didn't even have to do anything.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Graphics Objects en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by