Normal Probability Plot in R

The normal probability plot is the graphical representation of data. This tutorial demonstrates how to plot the normal probability in R.
Normal Probability Plot in R
The normal probability plot shows the normal distribution of the given data set. It compares the dataset with the normal distribution.
It should show a straight line if the data is normally distributed. We can use the ggplot2
with the ggplotr
package to plot the normal probability graph.
First of all, install these packages:
install.packages("ggplot2")
install.packages("qqplotr")
Once the packages are successfully installed, we create a data set for normal distribution, for which we will plot the normal probability graph. We will use the functions stat_qq_point()
and stat_qq_line()
to plot the normal probability.
See example:
install.packages("ggplot2")
install.packages("qqplotr")
library(ggplot2)
library(qqplotr)
# random data for normal distribution
normal_distribution = rnorm(1000, mean = 110, sd = 60)
# plot the data without line and labels
ggplot(mapping = aes(sample = normal_distribution)) + stat_qq_point(size = 3)+ stat_qq_line(color="green")
The code above will plot the graph for the normal probability of given data with a green straight line. See output:
Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.
LinkedIn FacebookRelated Article - R Plot
- Create a Ggplot2 Visualization With a Transparent Background
- scale_fill_continuous in R
- Create a 3D Surface Plot From (x,y,z) Coordinates
- Create a 3D Perspective Plot in R
- Plot Background Color in R