SCATTER PLOT DIFFERENT COLOURS

2 visualizaciones (últimos 30 días)
diala yazbeck
diala yazbeck el 23 de Feb. de 2021
Comentada: Just Manuel el 2 de Mzo. de 2021
hello!
so i have a table with 5 columns.
column 1 has values 1-12 (but this can vary depending on the data set), column 2 is time, column 3 is either 1 or 0 (right/left), and column 4 and 5 are x and y co-ordinates respectively.
I am trying to graph all of column 4 and 5 against column 3. all is well.
HOWEVER i need the colour of the graph to be blue if value in column 3 = 1 and red if = 0.
so the overall graph needs to look like this.
the script for this code is as follows
gscatter(COP_num(:,4), COP_num(:,5), COP_num(:,3), 'brbrbrg', '.')
legend({'right foot (blue)', 'left foot (red)', 'i dont know'})
title('Centre of Pressure data exported from GaitRite')
xlabel('X COP values'); ylabel('Y COP values');
set(gca, 'YDir', 'reverse');
hold
i NEED to try get it so that it is automatic and can apply to anything.
if the data is not 0 or 1 i want it to be green.

Respuesta aceptada

Just Manuel
Just Manuel el 23 de Feb. de 2021
Split your x/y data into two sets; one for right, one for left, then plot those.
x_left = COP_num(COP_num(:,3) == 0,4);
y_left = COP_num(COP_num(:,3) == 0,5);
x_right = COP_num(COP_num(:,3) == 1,4);
y_right = COP_num(COP_num(:,3) == 1,5);
hold on
scatter(x_left,y_left);
scatter(x_right,y_right);
Cheers
Manuel
  1 comentario
Just Manuel
Just Manuel el 2 de Mzo. de 2021
Please accept the answer, if it was of use to you.
Cheers
Manuel

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Colormaps 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