Scatter plot - plot different symbols when data is negative
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Greetings all,
I'm trying to differentiate positive and negative data on a plot by representing it with different symbols (i.e. 'o' and 'x', wheere the 'x' would represent negative data), but I'm not having any luck with it.
Here's what I tried:
figure(4)
scatter(sigma2new_Case1,sigma1new_Case1)
while(sigma2new_Case1 < 0)
plot(sigma2new_Case1,sigma1new_Case1,'x');
end
The statement in the "while" - I tried scatter in there but it didn't make any difference - I still get a plot full of 'o's.
Obviously I'm doing something wrong, and if someone could provide suggestions that would be greatly appreciated.
Thanks! Jesse
0 Commenti
Risposta accettata
Joseph Cheng
il 28 Apr 2015
Modificato: Joseph Cheng
il 28 Apr 2015
well what you're missing is any indexing inside your while loop to check which are less than 0 and basically comparing all of sigma2new_Casel to be <0. You can first figure out which items are <0 and then just plot each one. something like this
y=randi(10,1,20)-5;
x = 1:20;
neg = y<0;
figure,plot(x(~neg),y(~neg),'+',x(neg),y(neg),'o')
3 Commenti
Joseph Cheng
il 28 Apr 2015
Modificato: Joseph Cheng
il 28 Apr 2015
so you're looking at data for fully negative values in X and Y. such that only in quadrant 1 of +x and +y will be marked as positive? if that is the case you'll need to perform more logical operators.
y=randi(10,1,20)-5;
x = (1:20)-10;
negy = y<0;
negx = x<0;
neg = negy|negx;
figure,plot(x(~neg),y(~neg),'+',x(neg),y(neg),'o')
Where in the above code looks at which items in each array is negative and performs the logical operator (OR).
My suggestion is to look at the what is trying to be accomplished in my example. are you really trying to plot sigma2new_case1 versus signma1new_case1? in anycase why you're getting the mismatch is that you're not comparing like with like.
For instance in your example sig2 is all positives and sig1 is all negatives.. then you cannot compare the two indexes with each other. as you'll be trying to plot nothing against something.
to break it down with words in pseudo code
plot(sigma2new_Case1(index locations of positive sigma1new_Case1),sigma1new_Case1(index locations of positive sigma1new_Case1),'+', sigma2new_Case1(index locations of negative sigma1new_Case1),sigma1new_Case1(index locations of negative sigma1new_Case1),'o')
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Scatter Plots 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!