Normal Probability Plot in R using ggplot2 (original) (raw)

Last Updated : 6 Aug, 2025

A normal probability plot is a graphical representation of the data. A normal probability plot is used to check if the given data set is normally distributed or not. It is used to compare a data set with the normal distribution. If a given data set is normally distributed then it will reside in a shape like a straight line.

**Example 1: We are plotting a Q-Q plot using only ggplot2 to visualize how sample data compares to a normal distribution using quantile points and a reference line.

install.packages("ggplot2") library(ggplot2) set.seed(1) random_values <- rnorm(500, mean = 90, sd = 50) ggplot(data = data.frame(sample = random_values), aes(sample = sample)) + stat_qq() + stat_qq_line(col = "blue")

`

**Output:

scatter

Output

**Example 2: Plotting data points with line using stat_qq_line() function.

library(ggplot2)

random_values = rnorm(500, mean = 90, sd = 50)

ggplot(mapping = aes(sample = random_values)) + stat_qq(size = 2, color = "red") + stat_qq_line(color = "green") + xlab("x-axis") + ylab("y-axis")

`

**Output:

ggplot

Output

The output will display a Q-Q plot that compares the sample data to a theoretical normal distribution. If the data is normally distributed, the points will closely follow the green reference line. Deviations from this line suggest departures from normality. The red dots represent the actual quantile values of the sample.