Plotting a normal distribution in R is one of the first skills that turns abstract statistics into something you can actually see. Which means whether you are a student trying to understand what a z-score means, a researcher checking whether your data behaves bell-shaped, or an analyst preparing figures for a report, R gives you several clean and flexible ways to draw that curve. The good news is that you do not need to be an advanced programmer: a single line of code using curve() and dnorm() is enough to produce a publication-ready bell curve, and a few more lines let you overlay real data, shade probability areas, and compare distributions side by side Not complicated — just consistent..
This is the bit that actually matters in practice.
Why Plot a Normal Distribution in R?
The normal distribution, also called the Gaussian distribution, is the backbone of many statistical methods. Its shape is defined by two parameters: the mean (μ), which sets the center, and the standard deviation (σ), which controls how spread out the curve is. Plotting it helps you:
- Visualize probability. The area under the curve between two points equals the probability of a value falling in that range.
- Check assumptions. Many tests (t-tests, ANOVA, linear regression) assume approximately normal residuals.
- Communicate results. A smooth curve is far more intuitive for an audience than a table of numbers.
- Teach concepts. Seeing how changing σ widens or narrows the curve makes the idea of spread concrete.
The Four Functions Behind Every Normal Plot
Before drawing anything, it helps to know the norm family in R. These four functions appear in almost every example you will ever write:
dnorm(x, mean, sd)— the density function. It returns the height of the curve at each value of x. This is what you plot.pnorm(q, mean, sd)— the cumulative probability, i.e., the area to the left of q.qnorm(p, mean, sd)— the quantile function, the inverse ofpnorm.rnorm(n, mean, sd)— generates random numbers from a normal distribution.
If you remember only one thing: dnorm() draws the curve, rnorm() creates fake data that looks like the curve.
Method 1: The Quickest Bell Curve with curve()
The curve() function is the fastest route from zero to a finished plot. It evaluates an expression over a range and draws the result as a line.
curve(dnorm(x, mean = 0, sd = 1),
from = -4, to = 4,
xlab = "z-score",
ylab = "Density",
main = "Standard Normal Distribution",
lwd = 2, col = "steelblue")
A few details worth noting:
- The
fromandtoarguments control the horizontal range. For a standard normal, −4 to 4 captures essentially the entire curve (99.99% of the area). lwdsets line thickness andcolsets the color.- Because
curve()accepts an expression inx, you can passmeanandsddirectly, which makes it easy to redraw with different parameters.
To add a reference line at the mean, use abline(v = 0, lty = 2).
Method 2: Histogram Plus Density Overlay
Real data is rarely perfectly normal, so a common workflow is to simulate or collect data and then compare it to the theoretical curve.
set.seed(123)
x <- rnorm(n = 1000, mean = 50, sd = 10)
hist(x,
probability = TRUE, # critical: makes the y-axis density, not counts
breaks = 30,
col = "grey85", border = "white",
main = "Simulated Normal Data (n = 1000)",
xlab