0
$\begingroup$

I have the data file like this:

{{16.3009, 5454}, {16.2118, 5463}, {15.8156, 5414}, {15.9585, 5515}, {16.2253, 5459}, {16.284, 5419}, {15.6112, 5389}, {15.7221, 5403}, {15.509, 5445}, {15.6993, 5401}, {15.961, 5400}, {16.6001, 5379}, {16.3766, 5411}, {16.4999, 5437}, {16.3784, 5483}, {16.9554, 5510}, {16.9463, 5482}, {17.2453, 5455}, {17.0854, 5476}, {16.9786, 5407}, {17.2081, 5425}, {17.4898, 5428}, {17.1521, 5457}, {17.8233, 5382}, {17.726, 5448}, {17.7837, 5400}, {17.5088, 5398}, {17.8232, 5454}, {18.4418, 5385}}

and I need to find the histogram density (probability) for my data and then get the -LOG from it and then plot the 3D plot from it? I tried too many ways but I could not figure it out, How? I can get the 3D graph from Histogram3D, but when I try to use the SmoothHistogram3D with the ScalingFunctions -> {"None", "None", "-Log"}, I got this error massage "Message text not found -- ({None,None,-Log}"

enter image description here

$\endgroup$
  • $\begingroup$ Where is your third dimension? $\endgroup$ – DPF Oct 20 '16 at 16:13
  • $\begingroup$ The third dimension would be the probability of distribution of {x,y} in the x-y surface. I need to get -LOG from this probability. $\endgroup$ – Parviz Oct 20 '16 at 16:29
  • $\begingroup$ Could you post a slightly larger dataset, $n\approx 20$? $\endgroup$ – Feyre Oct 20 '16 at 16:32
  • $\begingroup$ {{16.3009, 5454}, {16.2118, 5463}, {15.8156, 5414}, {15.9585, 5515}, {16.2253, 5459}, {16.284, 5419}, {15.6112, 5389}, {15.7221, 5403}, {15.509, 5445}, {15.6993, 5401}, {15.961, 5400}, {16.6001, 5379}, {16.3766, 5411}, {16.4999, 5437}, {16.3784, 5483}, {16.9554, 5510}, {16.9463, 5482}, {17.2453, 5455}, {17.0854, 5476}, {16.9786, 5407}, {17.2081, 5425}, {17.4898, 5428}, {17.1521, 5457}, {17.8233, 5382}, {17.726, 5448}, {17.7837, 5400}, {17.5088, 5398}, {17.8232, 5454}, {18.4418, 5385}} $\endgroup$ – Parviz Oct 20 '16 at 16:39
  • $\begingroup$ So what code did you use to acquire that plot you added? $\endgroup$ – Feyre Oct 20 '16 at 16:50
3
$\begingroup$
data = {{16.3009, 5454}, {16.2118, 5463}, {15.8156, 5414}, {15.9585, 
    5515}, {16.2253, 5459}, {16.284, 5419}, {15.6112, 5389}, {15.7221,
     5403}, {15.509, 5445}, {15.6993, 5401}, {15.961, 5400}, {16.6001,
     5379}, {16.3766, 5411}, {16.4999, 5437}, {16.3784, 
    5483}, {16.9554, 5510}, {16.9463, 5482}, {17.2453, 
    5455}, {17.0854, 5476}, {16.9786, 5407}, {17.2081, 
    5425}, {17.4898, 5428}, {17.1521, 5457}, {17.8233, 5382}, {17.726,
     5448}, {17.7837, 5400}, {17.5088, 5398}, {17.8232, 
    5454}, {18.4418, 5385}};

 SmoothHistogram3D[data]

enter image description here

here is a "Log" scaling function. ( I could not get any kind of reasonable plot without manually specifying the plot range )

SmoothHistogram3D[data, ScalingFunctions -> {None, None, "Log"}, 
 PlotRange -> {-12, -5}

]

if you want "-Log" you need to specify a custom function:

 SmoothHistogram3D[data, ScalingFunctions -> {None, None, -Log[#] &}, 
     PlotRange -> {5, 12}]

enter image description here

The failure of automatic plot range to work may be a bug.

$\endgroup$
  • $\begingroup$ Thank you for your help, but still one problem, when I use the -Log[#] & , I am getting the plot (I add it to my question above) which it does not make any sense for me, but when I use the LOG, the graph is exactly what it should be. $\endgroup$ – Parviz Oct 21 '16 at 16:15
  • $\begingroup$ If you want to use log. Histogram3D[data, ScalingFunctions -> {None, None, "Log"}] $\endgroup$ – MinHsuan Peng Oct 26 '16 at 20:24
2
$\begingroup$
data = {{16.3009, 5454}, {16.2118, 5463}, {15.8156, 5414}, {15.9585, 
    5515}, {16.2253, 5459}, {16.284, 5419}, {15.6112, 5389}, {15.7221, 
    5403}, {15.509, 5445}, {15.6993, 5401}, {15.961, 5400}, {16.6001, 
    5379}, {16.3766, 5411}, {16.4999, 5437}, {16.3784, 5483}, {16.9554, 
    5510}, {16.9463, 5482}, {17.2453, 5455}, {17.0854, 5476}, {16.9786, 
    5407}, {17.2081, 5425}, {17.4898, 5428}, {17.1521, 5457}, {17.8233, 
    5382}, {17.726, 5448}, {17.7837, 5400}, {17.5088, 5398}, {17.8232, 
    5454}, {18.4418, 5385}};

To get the ranges of the data

{xmin, xmax} = MinMax[data[[All, 1]]];

{ymin, ymax} = MinMax[data[[All, 2]]];

distr = SmoothKernelDistribution[data];

To plot the probability density function (PDF) of the distribution

skd = Plot3D[PDF[distr, {x, y}],
  {x, xmin, xmax}, {y, ymin, ymax},
  PlotStyle -> Opacity[0.7],
  ColorFunction -> ColorData["TemperatureMap"]]

enter image description here

To scale the Histogram3D as a PDF

Energy1 = Histogram3D[data, Automatic, "PDF",
  ColorFunction -> ColorData["TemperatureMap"],
  ChartStyle -> Opacity[0.7]]

enter image description here

Show[skd, Energy1]

enter image description here

The results should be better with the full data set.

$\endgroup$

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.