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.

Not really a question, more a solution to what I call a bug in mathematica v8(.0.0.4). I already sent a bug report to Wolfram.


The documentation for the Histogram-function explains the following option.

{"Log",bspec}       apply binning bspec on log-transformed data.

When specifying the bins in the format {xMin, xMax, dx}, these values are not processed corretly which leads to insatisfying results.

In detail, the lower and upper bounds are transformed to the logarithmic scale using the natural logarithm. From there on, the bin widths are determined using dx and these bin coordinates are transformed back using the common logarithm. One would expect that the routine uses either the natural or the common logarithm for both operations, but not a mixture of the two.


Imagine, that data is a list of real values.

(* binning settings *)
binMin = 0.01;
binMax = 100;
binWidthLog = 1;
Histogram[data, {"Log", {binMin, binMax, binWidthLog}}]

Standard histogram

The minimum and maximum x values clearly don't follow the wanted behaviour. Using custom bin limits, this result can be reproduced as follows with a mixture of common and natural logarithms.

bins = {10^Range[Log[E, binMin], Log[E, binMax], binWidthLog]};
Histogram[data, {"Log", bins}]

Reproduced standard histogram

Might I suggest splitting off the "Solution" portion into an honest-to-goodness answer? After all, answering your own questions is kosher here... –  J. M. Nov 14 '12 at 13:26
I followed your advice, thanks. –  mincos Nov 14 '12 at 13:34
should the question be tagged as "bug"? –  Mike Honeychurch Nov 14 '12 at 22:10
I'll do that as soon as I can accept the answer (apparently takes two days). –  mincos Nov 15 '12 at 8:08

1 Answer 1

up vote 9 down vote accepted


The fix is obvious, just use one of the two logarithms consistently for the custom bins.

bins = {10^Range[Log[10, binMin], Log[10, binMax], binWidthLog]};
Histogram[data, {"Log", bins}]

Histogram fixed

I took me quite some time to figure this out so I thought i might be useful to post this here.


This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .