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.

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
add comment

3 Answers

up vote 9 down vote accepted

You can simply get the SmoothKernalDistribution 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
add comment

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
add comment

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
add comment

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.