How can I plot the indices of observation in class 1?

4 views (last 30 days)
How can I plot indices of observation in class 1 in red on the same plot?
current code I have for class 0:
>> I = find(ttr == 0);
>> scatter(Xtr(I,1), Xtr(I,2), 10, ’b’);
>> hold on;
I need indices of observation in class 1 for be red in the same plot

Answers (1)

KSSV
KSSV on 4 Sep 2020
Edited: KSSV on 4 Sep 2020
load tremor(1).mat ;
id1 = ttr==0 ;
id2 = ttr == 1 ;
plot(Xtr(id1,1),Xtr(id1,2),'*r') ;
hold on
plot(Xtr(id2,1),Xtr(id2,2),'*b') ;
OR
scatter(Xtr(:,1),Xtr(:,2),[],ttr)
Also read about gscatter.
  6 Comments
uzoma bob
uzoma bob on 4 Sep 2020
I think the issue was I was closing the plot rather than loading the second plot

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!