Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 12 down vote accepted

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}]
share|improve this answer

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

share|improve this answer

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.

share|improve this answer

Your Answer


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.