1
$\begingroup$

I produced an histogram using this simple code:

Histogram[{data}]

where data is a set of 100 values. The result was: enter image description here

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

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?

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

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]

Mathematica graphics

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

Mathematica graphics

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

Your Answer

By clicking ā€œPost Your Answerā€, you agree to our terms of service, privacy policy and cookie policy

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