I am trying to make a density plot to show the data that can found here. I tried with GNUplot previously. The result of GNUplot density plot for a rectangular set of data. I am able to do this only for a square (n x n) data set of the type:

x_1, y_1, z_1
x_n, y_n, z_n

where n is the number of lines.

The file that I post here is different. It is more similar to the one in the example from ListLinePlot page, which shows how to make a density plot for a spherical distribution of numbers.

Now the question is: Can I make the density plot of this data set with listdensityplot in Mathematica? The 2D map of the x-y is like that 2D map and the 3D map. As You can see all the points are in particular regions of the plot. So I expect that the density map works only in this part of the space (something simliar to this link Spreading colors in ListDensityPlot)


2 Answers 2

d = Import["https://federico.bitrix24.com/docs/pub/10347a058a3a38a8bd8232155c080e51/?LoadFile=1"];

Using 2D binning code from that great topic it is quite fast to obtain what you need:

zvalues = Log10@d[[All, 3]];
epsilon = 1*^-10;
indexes = 1 + Floor[(1 - epsilon) 512 Rescale[d[[All, {1, 2}]]]];
              "SparseArrayOptions" -> {"TreatRepeatedEntries" -> (Total[{##}] &)}];
binmeansZ = SparseArray[indexes -> zvalues];
              "SparseArrayOptions" -> {"TreatRepeatedEntries" -> First}];

MatrixPlot[GaussianFilter[binmeansZ\[Transpose], 2], DataRange -> {{-2, 2}, {-2, 2}}]

enter image description here

  • $\begingroup$ Is this what you are after? $\endgroup$
    – Kuba
    May 4, 2014 at 11:27
  • $\begingroup$ Perfect, last think: is it possible to make some smoothing of the points or not? $\endgroup$ May 4, 2014 at 13:01
  • $\begingroup$ You can make not 512 but more bins and the use weider GaussianFilter. $\endgroup$
    – Kuba
    May 4, 2014 at 13:07

The example that you showed makes it clear that the plot should use a logarithmic scale. So after importing your data as a list called d, I rescale them as follows:

rescaled = {#1, #2, Log[#3]} & @@@ d;

ListDensityPlot[rescaled, InterpolationOrder -> 0, PlotRange -> All, 
 ColorFunction -> Hue]


There seem to be some data missing, and the plot takes a minute or so because it is very large.

  • $\begingroup$ Yes in the sense that all the data is localized in a particular regions of the space and not in a rectangular form, as the graph I show to You. $\endgroup$ May 4, 2014 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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