Get Started →
Distribution Numerical

Histogram

ggplot2: geom_histogram() · Package: ggplot2 · Variables: 1 numerical

WHAT IS A HISTOGRAM?

A histogram groups a continuous variable into equal-width bins and shows the frequency (count) in each bin as a bar. It reveals the distribution shape — is it symmetric, skewed left or right, bimodal, or uniform? Histograms answer "how is my data distributed?" and are essential for understanding spread, central tendency, and outliers before any deeper analysis. The number of bins matters: too few bins hide patterns, too many create noise. A common rule of thumb is the square root of n. In ggplot2, use geom_histogram() and adjust the bins or binwidth parameter.

BEST FOR

  • · Understanding distribution shape
  • · Identifying skewness
  • · Finding outliers
  • · Assessing spread

AVOID WHEN

  • · Categorical data
  • · Very small samples (under 20)
  • · Comparing many groups simultaneously

R + GGPLOT2 CODE EXAMPLE

ggplot2
ggplot(mtcars, aes(x = mpg)) +
  geom_histogram(bins = 12, fill = "#ff6a00", color = "white") +
  labs(title = "Distribution of MPG", x = "MPG", y = "Count")

Run this code now

Paste the code above into RChat and see the histogram rendered instantly in your browser.

Try RChat Free →

SIMILAR CHART TYPES

ALTERNATIVES FOR YOUR DATA TYPE