I have some discrete data in the form {{x1,y1},{x2,y2},...} and when I produce a ListLogLogPlot they look like this:

2D discrete data

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):

SmoothDensityHistogram result

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:

SmoothDensityHistogram result with log scaling

The data that produce the first plot can be obtained here.

  • $\begingroup$ Have you looked at ListDensityPlot? $\endgroup$
    – Carl Woll
    May 2 '17 at 22:18
  • $\begingroup$ @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. $\endgroup$
    – leosenko
    May 2 '17 at 22:46
  • $\begingroup$ My bad. I think that SmoothDensityHistogram should work, but there seems to be an issue with the ScalingFunctions option. $\endgroup$
    – Carl Woll
    May 2 '17 at 23:02
  • $\begingroup$ If the set of points is a simple random sample from a bivariate probability distribution, you should try SmoothKernelDistribution[smbdataSpin[[All, 1 ;; 2]]]. $\endgroup$
    – JimB
    May 3 '17 at 0:02
  • $\begingroup$ Another approach is hexagon binning: mathematica.stackexchange.com/questions/28149/…. $\endgroup$
    – JimB
    May 3 '17 at 0:05

Possibly the following is what you're looking for?

    Log @ data,
    FrameTicks -> {
        {Charting`ScaledTicks[{Log, Exp}], Charting`ScaledFrameTicks[{Log, Exp}]},
        {Charting`ScaledTicks[{Log, Exp}], Charting`ScaledFrameTicks[{Log, Exp}]}

enter image description here


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];

 Ticks -> ticks,
 ColorFunction -> Function[{height}, ColorData["TemperatureMap"][height]]]

enter image description here

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

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.