Coloring scatterplots based on frequency of point occurrence in input
古いコメントを表示
Hello,
I have an input file (.txt) that is approximately 10,000 data points, all of the form "x y"
I know that many of the points are repeats. Is it possible to, when I load and scatterplot this data, to color points based on how frequently they occur in the input? For instance the color could be (R,G,B) = (f,f,f) where f is the amount of times the point appears in input.
My current code (that makes all points the same blue color) looks like this:
data=load('input.txt')
scatter(data(:,1),data(:,2),0.3)
I am new to Matlab (but not to programming) so the more explanation the better!
Thank you in advance.
採用された回答
その他の回答 (3 件)
Image Analyst
2012 年 2 月 13 日
0 投票
You can pass in the colors of each point. The trick is that you first have to call hist(data) to find the frequency of each range of your data and assign that to a particular color. I think you can do it - it's not that hard. Give it a shot. If you really can't come back for help.
2 件のコメント
Alex V
2012 年 2 月 13 日
Image Analyst
2012 年 2 月 13 日
I see. And what do you think the histogram does? Do you think that it might "for every x coordinate count how many times the same y coordinate appears"? Now you have two people telling you to use the hist.
Sukuchha
2012 年 2 月 14 日
Hi image analyst and jiro,
I tried to follow your instruction but couldnot succeed !
This is what i did.
A = fix(rand(100,1)*10);
B = fix(rand(100,1)*10);
AB =[A B];
sort_AB = sort(AB,1);
[n,xout] = hist(sort_AB)
But, with hist command, n is nx2 matrix where each columns of sort_AB is taken independently. So n will not give me, how many points are within 10 equally divided range.
And also please explain how to make a C matrix?
A example with code will surely make things clear :)
Anita Joshi
2017 年 6 月 17 日
0 投票
Hallo everyone, I would like to print the number of occurance of the 2D data in the same graph.. how do I do it?
カテゴリ
ヘルプ センター および File Exchange で Discrete Data Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!