# I want to plot 3Dhistogram from my data?

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}"

• Where is your third dimension?
– DPF
Commented Oct 20, 2016 at 16:13
• 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. Commented Oct 20, 2016 at 16:29
• Could you post a slightly larger dataset, $n\approx 20$? Commented Oct 20, 2016 at 16:32
• {{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}} Commented Oct 20, 2016 at 16:39
• So what code did you use to acquire that plot you added? Commented Oct 20, 2016 at 16:50

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]


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


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

• 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. Commented Oct 21, 2016 at 16:15
• If you want to use log. Histogram3D[data, ScalingFunctions -> {None, None, "Log"}] Commented Oct 26, 2016 at 20:24
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"]]


To scale the Histogram3D as a PDF

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


Show[skd, Energy1]


The results should be better with the full data set.