I have the following problem: I need to build the scatterplot of the data. Everything nice, but there is some duplicate data there:
x = [11, 10, 3, 8, 2, 6, 2, 3, 3, 2, 3, 2, 3, 2, 2, 2, 3, 3, 2, 2];
y = [29, 14, 28, 19, 25, 21, 27, 15, 24, 23, 23, 18, 0, 26, 11, 27, 23, 30, 30, 25];
One can see that there are two elements with (2, 25); (2,27); (3,24);
So if to build this data with a regular scatter(x,y) I am loosing this information:

The way out of this I have found is to use undocumented 'jitter' parameter
scatter(x,y, 'jitter','on', 'jitterAmount', 0.06);
But I do not like the outlook:

What I was trying to achieve is this:

Where the number of duplicates is next to the point (if the number is more than 1), or may be inside the point.
Any idea how to achieve this?
You can do that pretty easily, let’s cut it down in two parts:
First you’re gonna need to identify the unique 2d points and count them. That’s what we have the unique and accumarray function for. Read through the documentation if you don’t immediately understand what they’re doing and what outputs they have:
Now each row of
Auniqcontains the unique 2d points, whilecntcontains the number of occurences of each of those points:For displaying the number of occurences, there are a great many possibilities. As you mentioned, you could put the numbers inside/next to the scatter markers, other options are color encoding, size of the markers,… let’s do all of these, you can also of course combine!
Number next to marker
Number inside marker
as you can see, I enlarged the size of the markers very simply with the scatter function itself.
Color encoding
after which you can add a colorbar or legend to indicate the number of occurences per color.