How to do a cumulative histogram on Mathematica on a log-log scale? This question is pretty straightforward, but a search didn't help me at all. Keep in mind that all I have is a list of n numbers Thanks for the help

  • 1
    $\begingroup$ s = RandomReal[{0, 1}, 100];BarChart@Log@Accumulate@BinCounts[s, .1] $\endgroup$ Commented Nov 24, 2014 at 21:14

2 Answers 2


With some random numbers

rNumbers = RandomReal[{0, 1}, 100]

you can get a cumulative histogram with a log-log scale using

Histogram[rNumbers, "Log", {"Log", "CumulativeCount"}]


  • $\begingroup$ +1 now I feel silly for doing it the hard way.. $\endgroup$
    – george2079
    Commented Nov 24, 2014 at 22:32
  • $\begingroup$ Thanks! But somehow I can't make it work with a log scale on the counts. If I just do Histogram[numbers,"Log","CumulativeCount"] it works, but as soon as I add the "Log" it gives me an error message: The height specification {Log,CumulativeCount} is not one of the named height functions or a function that can be used to compute the heights for each bin. $\endgroup$
    – bernie
    Commented Nov 25, 2014 at 21:39
  • $\begingroup$ @bernie you have to use quotation marks: {"Log", "CumulativeCount"} $\endgroup$
    – Karsten7
    Commented Nov 26, 2014 at 8:36
 data = RandomVariate[NormalDistribution[2, .1], 100];
 ListPlot[ Transpose[{Mean /@ Partition[#[[1]], 2, 1],
     Accumulate@#[[2]]}] &@HistogramList[ data ] ,
     Filling -> Axis, PlotRange -> {0, Automatic}]

enter image description here

 BarChart[ Accumulate@#[[2]] &@ HistogramList[ data ] ]

enter image description here

Edit :

missed the loglog part earlier, properly we need to cook up logarithmic bins: ( or go read the Histogram docs and see that this is built in.. )

 data = RandomVariate[WeibullDistribution[  10, 1 ], 100000];
 logbins = N@Exp[FindDivisions[  Log[ Sort[data][[{1, -1}]] ] , 10 ]]
 BarChart[ Log@Accumulate@BinCounts[ data ,  {logbins}] , 
     ChartLabels -> Mean /@ Partition[logbins, 2, 1]]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.