ggplot2 facet wrap - scales "free_y" not working as expected

Hi all, I am trying to plot histograms showing the distribution of water consumption volumes (column 'volume_kgal') by different classes of customer (column 'class').

When I try to plot this as a histogram, the bars for some customer classes are "compressed" on the vertical axis, even though I used the argument scales = "free_y".

Please see below, where "Irrigation" and "Irrigation Summer" plots do not make use of the full vertical axis:

Here is my code:

df_all |> 

  ggplot(aes(x = volume_kgal)) +
  geom_histogram(binwidth = 1, alpha = 1, fill = "#4472C4") +  
  facet_wrap(~ class, 
             ncol = 1, 
             scales = "free_y", 
             ) +  
  labs(
    title = "Distribution of Volumes by Class",
    x = "Volume",
    y = "Density"
  ) +
  scale_x_continuous(limits = c(0, 30)) +  # 
  theme_minimal() +
  theme(
    strip.text = element_text(size = 11, face = "bold")  # Customize facet labels
  )

Any ideas on how to fix this? I have tried removing the scale_x_continuous line but that doesn't help. Thank you!

If you have a lot of 0 values for Irrigation and Irrigation Summer, set the x limits to c(-0.5, 30) to see those values show up in the histogram.

example

library(ggplot2)

df_all <- tibble::tibble(
  class = sample( c("Commercial", "Irrigation","Irrigation Summer", "Residential"), 1e5, replace = TRUE),
  volume_kgal = floor(runif(1e5, 0, 30))
) 

foo <- tibble::tibble(
  class = rep("Irrigation", 1e4),
  volume_kgal = rep(0, 1e4)
  )

df_all |> 
  rbind(foo) |>
  ggplot(aes(x = volume_kgal)) +
  geom_histogram(binwidth = 1, alpha = 1, fill = "#4472C4") +  
  facet_wrap(~ class, 
             ncol = 1, 
             scales = "free_y", 
  ) +  
  labs(
    title = "Distribution of Volumes by Class",
    x = "Volume",
    y = "Density"
  ) +
  scale_x_continuous(limits = c(-.5, 30)) +  # 
  theme_minimal() +
  theme(
    strip.text = element_text(size = 11, face = "bold")  # Customize facet labels
  )