2
$\begingroup$

The problem is easy to reproduce.

Try

Histogram[RandomInteger[{-205, 205}, 10000]]

I got

enter image description here

What is wrong with the boundary bar? They supposed to be the same height as other bars.

Ps: I am using Mathematica 10.4

$\endgroup$
4
  • 4
    $\begingroup$ HistogramList@RandomInteger[{-205, 205}, 10000] or x axis will tell you that the first and last bins starts at +-220 $\endgroup$
    – Kuba
    Commented Aug 12, 2016 at 14:35
  • 4
    $\begingroup$ Workaround: Histogram[RandomInteger[{-205, 205}, 10000], {-205, 205, 20}] $\endgroup$
    – Karsten7
    Commented Aug 12, 2016 at 14:36
  • $\begingroup$ @Kuba That makes thing clear. Thank you Kuba $\endgroup$
    – matheorem
    Commented Aug 12, 2016 at 14:55
  • $\begingroup$ @Karsten7. This works, Thank you Karsten7 $\endgroup$
    – matheorem
    Commented Aug 12, 2016 at 14:56

1 Answer 1

7
$\begingroup$

There are two things worth explained here.

  1. The bins in Histogram and its family functions are all left closed, right open. Integer data, most of the times, shows this behavior.

  2. As @Karsten7 suggested, specifying bin spec {-205, 205, 20} will work on this case. Histogram, by default, is trying to find "nice" bin delimiters, thus {-220, 220, 20}, which goal is to cover all data points and to give a reasonable number of bars, besides nice cut-offs.

$\endgroup$

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.