showing different parts of a dataset with different symbols in a scatterplot

Hello there
I have a small and confusing question, would you please tell me how to show my data with different symbols within a scatter plot?? lets say I wanna create a scatter plot which has 60 inputs, I would like to show the first 20 with for instance triangle, the next 10 with circles and the rest with asterisks. I think it could be easy but I got totally confused about it. thank you all in advance

Answers (3)

% Synthetic data
x = rand(60,1);
y = rand(60,1);
% Plotting
scatter(x(1:20),y(1:20),'r*');
hold on
scatter(x(21:30),y(21:30),'b^');
scatter(x(31:end),y(31:end),'g<');
Dear Sean but when i want to add the refline line it gives me three reflines I just wanna have one for the whole scatter plot

1 Comment

Then calculate the refline coefficients with polyfit with the whole dataset:
% Synthetic data
x = cumsum(rand(60,1));
y = cumsum(rand(60,1));
% Plotting
scatter(x(1:20),y(1:20),'r*');
hold on
scatter(x(21:30),y(21:30),'b^');
scatter(x(31:end),y(31:end),'g<');
mb = polyfit(x,y,1);
refline(mb)

Sign in to comment.

Products

Asked:

on 12 Nov 2014

Commented:

on 13 Nov 2014

Community Treasure Hunt

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

Start Hunting!