showing different parts of a dataset with different symbols in a scatterplot
Show older comments
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)
Sean de Wolski
on 12 Nov 2014
% 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<');
Nima
on 12 Nov 2014
0 votes
Nima
on 12 Nov 2014
0 votes
1 Comment
Sean de Wolski
on 13 Nov 2014
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)
Categories
Find more on Scatter Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!