I have some data that I want to plot in MATLAB. The data consists of x and y coordinates of the points that I want. At the moment, I am using the plot function to plot these points.
The data has a lot of points with the same coordinates. Now, what I want is that points with the same coordinates do not plot as a single dot, but a thicker dot.
For example, suppose the points are
1,1
2,1
2,1
3,2
2,1
2,1
1,1
Then, the plot should have a single dot at 3,2, but a thicker dot at 1,1 and even a thicker dot at 2,1
Can someone tell me how to do this?
You can use a bit of creativity and the
scatterfunction to do this.First, you need to reduce your data to a list of points, plus a count of the number of points at each location.
For example if you have some data:
Get the unique points, and the unique indexes:
This is pretty painful, but we can count the number of occurrences of each unique row using the
ixsvector (there is probably a better way).Now use scatter to make a plot as you want