# Rescale x-axis of an Histogram with fixed bins

I produced an histogram using this simple code:

Histogram[{data}]


where data is a set of 100 values. The result was:

I now would like to "rescale" the x-asis in order to obtain something like this

I tried with Histogram[{data}, {{1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048,4096}}] but it didn´t work because in the x-axis there are still all bins, not only the one I want.

Do you have any idea on how to solve my problem?

• For these particular bins why not just perform a Histogram using Log[2,data] ? – JimB Apr 28 '17 at 14:21
• Why not PlotRange-> {{x0,x1},All} - that's separate from the bin range/width spec - ie, 2nd argument to Histogram. – alancalvitti Jul 8 '17 at 16:45

## 1 Answer

Obtain bar heights using HistogramList with your bin specification, and use the result in BarChart:

data = RandomVariate[WeibullDistribution[2, 5], 1000];
binspec = {Prepend[2^Range[0, 13], 0]};
xlabels = Rotate[Style[#, 16, "Panel"], Pi/2] & /@ Append[binspec[[1, 2 ;; -2]], Infinity];

heights1 = HistogramList[data, binspec, "Count"][[2]];
BarChart[heights1, ChartLabels -> xlabels, BarSpacing -> 0]


heights2 = HistogramList[data, binspec, "Probability"][[2]];
BarChart[heights2, ChartLabels -> xlabels, BarSpacing -> 0]


• Thank you so much for solving my problem @kglr ! – alphabeta Jun 12 '17 at 13:07
• @alphabeta, my pleasuer. Welcome to mma.se. – kglr Jun 12 '17 at 15:55