How to make this plot

10 visualizaciones (últimos 30 días)
Stefano Di Vito
Stefano Di Vito el 31 de Mayo de 2018
Comentada: Stefano Di Vito el 31 de Mayo de 2018
Hello! I'd like an help to find the right way to make the following plot. I have a logical matrix, with values true (1) and false (0). This matrix has dimensions (P, T). Let's say T is the time window vector, and P represents my variables. I want to plot their value for each time window, by this way:
  • If the value of the cell is true, then it is marked by a green circle
  • If the value of the cell is false, then it is marked by a red circle
The result should be a column of circles, green and red, for each column of the matrix, so i should obtain T columns of circles, one after the another. The Y-axis should have the number of P-variables as measure, while X-axis should have a vector of dates, like the following one: T_1,T_2,......,T_155 (how can i name it in this way?)
For istance, i have P=80 variables. For each of these 80 variables, i should plot the value they assume in each time window, so i should have a column of 80 circles, for a fixed time window.
  2 comentarios
Stephen23
Stephen23 el 31 de Mayo de 2018
@Stefano Di Vito: what have you tried so far?
Stefano Di Vito
Stefano Di Vito el 31 de Mayo de 2018
Hi!
Treb=155
T=[1:155]
hold on
ylim([0 80]);
xlim([0 155]);
for j=T(1)
for i=1:P
if M(i,j)~=0
plot(T(j),M(i,j),'Marker','o','MarkerFaceColor','r','Markersize',3,'MarkerEdgeColor','k')
else
plot(T(j),M(i,j),'Marker','o','MarkerFaceColor','g','Markersize',3,'MarkerEdgeColor','k')
end
end
end
hold off
I tried this, starting from the first column; but i get only two points; how can i do to plot each point? and how can i set the cycle to repeat for each column of the matrix? M is a (P,Treb) matrix

Iniciar sesión para comentar.

Respuestas (1)

Paridhi Yadav
Paridhi Yadav el 31 de Mayo de 2018
Hey, you can extract the data of P in two different vectors, one with all true(1) value and one with false(0) and plot both of them one over other using "hold on".

Community Treasure Hunt

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

Start Hunting!

Translated by