# How can I set the leftmost x-value of a Histogram?

The following code:

repeat[m_, n_Integer?Positive] := Sequence @@ ConstantArray[m, n]
data = {repeat[71, 2], repeat[73, 3], repeat[74, 5], 76, repeat[77, 3], 78, 80}
Histogram[data, {2}, "Probability"]


Produces the following histogram:

Since the least data point is 71 and the bin width is 2, the first bin, unsurprisingly, starts at 70. Keeping the bin width at 2, how can I force it to start at 70.5?

• If you look at the Details section of the Histogram documentation, you'll find that you can give a bin specification as {xmin, xmax, dx}, so in your case perhaps Histogram[data, {70.5, 82, 2}, "Probability"]? Apr 18, 2021 at 19:35
• @MarcoB Thank you, Histogram[data, {70.5, 80.5, 2}, "Probability"] did the trick. For reference, I used 80.5 because the largest value in the dataset (80) is in the [78.5, 80.5] bin. Do you want to post that as an answer for me to accept? Apr 18, 2021 at 20:24
• Lucca, I'm glad it helped. I'd recommend that you post a self-answer with that information and the extra modification you made to suit your dataset. Self-answers are encouraged here! Apr 18, 2021 at 21:25

Histogram[data, {70.5, 80.5, 2}, "Probability"] did the trick. I used 80.5 because the largest value in the dataset (80) is in the [78.5, 80.5] bin.