Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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)

share|improve this question

2 Answers 2

up vote 4 down vote accepted
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}]]]];
System`SetSystemOptions[
              "SparseArrayOptions" -> {"TreatRepeatedEntries" -> (Total[{##}] &)}];
binmeansZ = SparseArray[indexes -> zvalues];
System`SetSystemOptions[
              "SparseArrayOptions" -> {"TreatRepeatedEntries" -> First}];


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

enter image description here

share|improve this answer
    
Is this what you are after? –  Kuba May 4 at 11:27
    
Perfect, last think: is it possible to make some smoothing of the points or not? –  Panichi Pattumeros PapaCastoro May 4 at 13:01
    
You can make not 512 but more bins and the use weider GaussianFilter. –  Kuba May 4 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]

plot

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

share|improve this answer
    
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. –  Panichi Pattumeros PapaCastoro May 4 at 10:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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