# How to deal with overlapping data points in ListPLot

I am plotting data using ListPlot, but many of my data points are exactly overlapping and so the density of the data is not shown clearly.

I wonder if there is a way to solve this, either by 'jittering' the points or by adjusting the size of the points to reflect the density of points at a particular coordinate. Any other ideas would be very welcome.

Considering you have duplicate points, you can use the number of times the data appears as your point size.

data = RandomReal[{0, 10}, {30, 2}];
data = Join[RandomChoice[data, 12], data]; (*duplicate data*)
data1 = Tally[data]; (*count number of appearance*)
Graphics[Disk[#[[1]], #[[2]] 0.1] & /@ data1, Frame -> True]


BubbleChart

As pointed by Edmund, you can use BubbleChart as well. I think it is better.

data2 = data1 /. {{x_, y_}, z_} -> {x, y, z}
BubbleChart[data2]


• Have you seen BubbleChart? Commented Mar 24, 2016 at 12:10
• thanks @Edmund. I did not know about BubbleChart. Commented Mar 24, 2016 at 12:26

Colour points in ListPlot using Style and your own colour function with Blend.

SeedRandom[123];
data = RandomInteger[{1, 5}, {100, 2}];


Create a colour function to colour each point. It will take the number of occurrences of the point. The function ranges from 1 to 10 over gray, orange, and blue.

colFunc = Blend[{{0, LightGray}, {.5, Orange}, {1, Blue}}, Rescale[#, {1, 10}]] &;


Use ListPlot's Style wrapper form for the data points. Also include a legend for the colours.

Legended[
ListPlot[Style[First@#, colFunc[Length@#]] & /@ Gather[data]],
BarLegend[{colFunc, {1, 10}}, All]]


Hope this helps.

If you have many points, consider SmoothHistogram3D. Borrowing the code from @Sumit to duplicate random points:

data = RandomReal[{0, 10}, {300, 2}];
data = Join[RandomChoice[data, 60], data];


Then

SmoothHistogram3D[data, 0.3]


where the second parameter adjust the sharpness of the smoothing.