This histogram shows the sampling distribution of 5000 sample proportions each based on 50 persons. Why are there gaps between the bars in the histogram?

enter image description here

  • 1
    $\begingroup$ Good question, although it looks like that might be a bar plot, meaning they binned height. $\endgroup$ Commented Feb 21 at 15:03
  • 5
    $\begingroup$ The proportion of $n=50$ is a discrete value in the set $\{0,0.02,0.04,\ldots,0.98,1.00\}.$ The software chose a bin width of approximately $0.01.$ As such the histogram is accurate by showing no values that are odd multiples of $0.01.$ $\endgroup$
    – whuber
    Commented Feb 21 at 18:18

3 Answers 3


You can adjust the breaks parameter in the hist function to have fewer bins. The first plot (51 bins) might not align perfectly with the exact sample proportions since it's just a count of breaks, not tied to the sample proportion scale. This could potentially lead to bins that don't correspond to the actual proportions possible with 50 samples, depending on how the histogram function handles the range of the data. The second plot would align the breaks exactly with the possible sample proportions, meaning each bin would correspond to an exact number of individuals in poverty $(0, 1, 2, ..., 50)$. Here is an R code

sim_samp_dist <- function(p, n, N, num_breaks) {
  # Initialize a vector to store the sample proportions
  sample_proportions <- numeric(N)
  # Simulate drawing samples and calculating sample proportions
  for(i in 1:N) {
    # Simulate a sample of individuals with a binomial distribution
    sample <- rbinom(n = n, size = 1, 
                     prob = p)
    # Calculate the sample proportion
    sample_proportions[i] <- sum(sample) / n
  # Create a histogram of the sample proportions
       breaks = num_breaks, # specify the number of breaks directly
       main = paste("Sampling Distribution of Proportion (n =", 
                    n, ")"),
       xlab = "Proportion", 
       ylab = "Frequency",
       right = FALSE) 

sim_samp_dist(p = 0.2, n = 50, N = 5000, 51) # 1st plot 
sim_samp_dist(p = 0.2, n = 50, N = 5000, seq(0, 1, by = 1/50)) # 2nd plot 

enter image description hereenter image description here

  • $\begingroup$ Detailed code in one unstated language for what you could (should?) do instead isn't really focused on the question. (I can guess what language this is.) $\endgroup$
    – Nick Cox
    Commented Feb 21 at 17:33
  • $\begingroup$ @NickCox Thank you for your feedback. I appreciate you taking the time to point out where my response could have been clearer. My intention was to provide a detailed solution that might be helpful for a variety of similar issues, but I realize now that I should have specified the programming language used (R). $\endgroup$
    – ADAM
    Commented Feb 21 at 18:04
  • 3
    $\begingroup$ The OP accepted your answer, which is their prerogative. Goodness knows why, as I still consider it does not answer the question. Happy to think it could be useful otherwise, as could be answers focused on code in any other language. $\endgroup$
    – Nick Cox
    Commented Feb 21 at 18:23

It's a bad plot - there should never be space between histogram bars binning continuous data. The plot as shown indicates there were no observations between 0.2 and 0.21 (or in any other gap), which is almost certainly not the intent.

It's fine to put space in between bars of a bar plot showing discrete categories since those gaps have no meaning, but you should never put gaps between histogram bars of continuous values, because those gaps do have meaning, showing no data was observed there.

It was an aesthetic choice to put gaps around the bars in the hope of making it easier to read. I would say that it's a poor choice, however, as including gaps around the bars has actually changed the data being represented.

  • 2
    $\begingroup$ (+1) Goodness knows why this was downvoted. It's fair comment and on target. (Personally, I am very happy with the idea that a bar chart showing frequencies of a discrete variable or even a categorical variable is also a histogram and that then showing bars with spaces in between is a fair convention, but heck, many people use histogram in this narrower sense, and they have cast their votes.) $\endgroup$
    – Nick Cox
    Commented Feb 21 at 15:57
  • 1
    $\begingroup$ I would be uncomfortable calling it a histogram rather than a bar chart: the tallest bar corresponds to about $13\%$ on the axis, which is presumably the proportion of samples in the bin $(2.2,2.4]$ or something like that. But if it were a histogram than you would need to multiply the height by the width, and that would give too small a number. $\endgroup$
    – Henry
    Commented Feb 21 at 16:42
  • $\begingroup$ @Henry A histogram just shows relative frequency, the proportion of the total sample is a rather natural unit. I'm not sure what you're getting at with the height x width multiplication, I'm not aware of that representing a useful value. It would have meaning for a probability distribution function with an area-under-the-curve of 1, but not a general histogram. $\endgroup$ Commented Feb 21 at 17:12
  • $\begingroup$ @Nuclear on the contrary, Henry is correct: a histogram by definition uses bar areas to represent probabilities, not bar heights. $\endgroup$
    – whuber
    Commented Feb 22 at 15:36

At first I thought it was just an aesthetic choice on the part of the chart's creator to add a little padding around bin, in the style of a bar chart. But whuber's comment is insightful: the proportion out of 50 is one of {0.00, 0.02, ..., 0.98, 1.00}, but the bin width is less than 0.02, creating the same effect.

In any case, a histogram is essentially a kind of bar chart, where the horizontal axis represents a notionally continuous variable that has been binned into discrete intervals.

In some cases, padding a histogram's bars might make the frequencies a little easier to read, but it comes at the cost of making the horizontal axis harder to interpret. Better axis labeling would have helped in this case.

  • 2
    $\begingroup$ There should never be space between histogram bars. Histograms represent bins of continuous data, spaces would indicate that there is no data observed between the bins being shown. The chart as shown indicates that there were exactly zero observations between 0.2 and 0.21, which almost certainly not what is intended. $\endgroup$ Commented Feb 21 at 15:34
  • $\begingroup$ Do you imagine that all continuous variables are measured with tools of infinite precision? $\endgroup$
    – jdonland
    Commented Feb 21 at 15:40
  • 2
    $\begingroup$ I have no idea what you're getting at. Whatever the observed value is, it must fall into one of the adjacent bins. The plot as shown suggests that some values can fall "between" bins, like a value of 0.201, but that can't happen in a histogram. Or are you suggesting this is real data that really does have gaps at intervals of 0.01 units? $\endgroup$ Commented Feb 21 at 15:44
  • 2
    $\begingroup$ As with the answer by @NuclearHoagie, this is fair comment. The downvote is hard to fathom. $\endgroup$
    – Nick Cox
    Commented Feb 21 at 15:59

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.