Box plots include a simple way of representing statistical data of the given plot in which the rectangle is drawn, including the second and third quartiles. The vertical line is used to indicate the median value, while the lower and upper quartiles are displayed on either side of the rectangle. We can create and customize the box plot using the steps mentioned as follows:
- Include the library within the R workspace. This is considered a mandatory step:
> library(ggplot2)
Attaching package: 'ggplot2'
The following object is masked _by_ '.GlobalEnv':
mpg
Warning message:
package 'ggplot2' was built under R version 3.5.3
- Use the required function, such as we did for scattered plots, to get the perpendicular plots arranged in a systematic manner:
> ggplot(data=Iris,aes(x=Species, y=SepalLengthCm,color=Species)) + geom_boxplot() +theme_minimal...