How can I create a smooth histogram with a log-log scale?

I can use Histogram[data, "Log", "LogCount"] to get a log-log histogram, or I can use SmoothHistogram[data] to get a smooth histogram, but is there a way to combine these two functionalities?


You can simply get the SmoothKernelDistribution and build the plot as you'd like:

data = Table[Sin[x]^3 + 1, {x, 0, 6 Pi, 0.1}];
dist = SmoothKernelDistribution[data];
LogLogPlot[PDF[dist, x], {x, 0.01, 2}]

Perhaps an approximation like this may help

Some data from the help:

sizes = FileByteCount /@  FileNames["*.nb", 
        FileNameJoin[{$InstallationDirectory, "Documentation", "English", 
        "System", "ReferencePages", "Symbols"}]];

Show[Histogram[sizes, "Log", "LogCount", Frame -> True], 
     ListLogLogPlot[Transpose[{Rest@#[[1]], #[[2]]} &@HistogramList[sizes, "Log", "LogCount"]], 
                    Joined -> True, InterpolationOrder -> 3, PlotStyle -> Red]]

Mathematica graphics


Combination of the answers of jVincent and belisarius:

dist = SmoothKernelDistribution[Log[sizes], 0.1];
Show[Histogram[sizes, "Log", "LogPDF", Frame -> True, PlotRange -> All], 
 LogLogPlot[PDF[dist, Log[x]]/x, {x, 10^3, 10^9}, 
  PlotRange -> 10^{-11, -4}, PlotStyle -> Red]]

enter image description here

It uses a smooth kernel with the uniform bandwidth 0.1 in the log scale.


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.