# Plot density of discrete data

I have some discrete data in the form {{x1,y1},{x2,y2},...} and when I produce a ListLogLogPlot they look like this: I would like to produce a density plot or map saying, how much packed the points are (I am not really sure, how this should be achieved though, my first idea is take a circle of a fixed radius centered on a given point and count how many neighbours there are and based on that assign value/colour but maybe this is nonsense). I found the most likely candidate to be SmoothDensityHistogram but it produces this (I admit, I do not understand this function much, I read help, but there everything works perfectly however they generate the data syntetically): But if I look at the first plot, quite obviously the plot I want should look like "a hot area in the center with tails to the north and east". There is an ovious another issue, how to force log scales to SmoothDensityHistogram, because when I use

SmoothDensityHistogram[smbdataSpin[[All, 1 ;; 2]], 0.1,
ScalingFunctions -> {Log, Log}]


I get something even more strange: The data that produce the first plot can be obtained here.

• Have you looked at ListDensityPlot? – Carl Woll May 2 '17 at 22:18
• @CarlWoll I know of it but unless I am missing something, that constructs the density from the values of the array which in my case makes little sense I think because e.g. {{1,1},{2,2}} would have the highest value of density in the top right corner but that is incorrect as it says nothing about the density of points in the plot. – leosenko May 2 '17 at 22:46
• My bad. I think that SmoothDensityHistogram should work, but there seems to be an issue with the ScalingFunctions option. – Carl Woll May 2 '17 at 23:02
• If the set of points is a simple random sample from a bivariate probability distribution, you should try SmoothKernelDistribution[smbdataSpin[[All, 1 ;; 2]]]. – JimB May 3 '17 at 0:02
• Another approach is hexagon binning: mathematica.stackexchange.com/questions/28149/…. – JimB May 3 '17 at 0:05

## 2 Answers

Possibly the following is what you're looking for?

SmoothDensityHistogram[
Log @ data,
Frame->True,
PlotRange->All,
FrameTicks -> {
{ChartingScaledTicks[{Log, Exp}], ChartingScaledFrameTicks[{Log, Exp}]},
{ChartingScaledTicks[{Log, Exp}], ChartingScaledFrameTicks[{Log, Exp}]}
}
] You can also do this in 3D

ticks = {
Table[{n, 10^n}, {n, -3, 3}],
Table[{n, 10^n}, {n, -2, 3}],
Automatic} /. r_Rational :> N[r];

Histogram3D[Log10[data],
Ticks -> ticks,
ColorFunction -> Function[{height}, ColorData["TemperatureMap"][height]]] SmoothHistogram3D[Log10[data],
Ticks -> ticks,
ColorFunction ->
Function[{x, y, height}, ColorData["TemperatureMap"][height]]] 