Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How can i change the colure of points in a scatter graph depedning on another function?

1 visualizzazione (ultimi 30 giorni)
I've got a table with three columns, T, A and B. I want to plot A against B. The points should be red when T is not in the range 0<T<90. However, I can not colour them properly. This is my script however an error comes up saying does not recognise the function "black".
x = T_onsetSEI(:,2) y = T_onsetSEI(:,3)
for i=1:20000 if T_onsetSEI(1,i) = range 0-90 c=blue else c=red end end figure;scatter(x,y,c,'filled')

Risposte (1)

SRT HellKitty
SRT HellKitty il 23 Feb 2018
I believe there are 2 things that are incorrect in this.
The first is that scatter() has variable inputs that are set to specific meanings. with the way you are using it the third should be the size of the points. you can use [] if you do not wish to change it, however you need to have it in there like this;
scatter(x,y,[],c,'filled')
The second thing is you can use logical indexing for this instead of a nested if statement. if you have a variable T which should be blue within 0<T<90 and red otherwise, you can do the following;
c = ones(size(T)); %Create an array of ones the same size as T
c = c*'r'; % there might be a better way to do this, but it sets all the ones in the array to the equivalent to red
c(0<T<90) = 'b'; % the points where T is between 0 and 90, c will be the equivalent to blue.

Questa domanda è chiusa.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by