Change size of outlier labels on boxplot in R
The boxplots in R Programming Language are used to label the data and take an assumption about how well distributed it is. The boxplot can be constructed using various data visualization packages in R, like the ggplot2 and the car packages. Outlier refers to the data points located outside the boundaries of the data. These are the data points that generally fall outside the proper boundaries of the other data points. It is possible to increase the size of the outliers.
Method 1: Using ggplot2 package
The ggplot2 package is used for data visualization and depicting the plots. This package can be downloaded and installed into the working space using the following command :
The ggplot method in this package is used to construct various kinds of plots, like scatter plots, box plots, etc. The plots take as input the data frame to be used and also supply aesthetic mappings using the x and y coordinates. Other arguments can be added by using the color specified by the grouping column.
The geom_boxplot() component can be added to the ggplot object in order to create a boxplot from the data specified. It takes as an argument the outlier.size in order to provide a size to the outlying points.
Syntax: geom_boxplot (outlier.size = )
outlier.size – The size of the outlying points of the box plot
 "Data Frame" > print(data_frame) col1 col2 1 a 1 2 b 2 3 a 3 4 a 4 5 b 5 6 a 12
Method 2: Using car package
The Companion to Applied Regression (car) package in R is used to apply the regression techniques to the data elements contained in R objects. The package can be downloaded and installed into the R working space using the following command :
The Boxplot method in R can be used to create boxplots with the feature of point identification.
Syntax: Boxplot( vec, data, labels, outcex )
- vec – The variable for which the boxplot is constructed
- data – The data table
- labels – The label to provide to the plotted data
- outcex – The size of the outlier
The following code snippet uses the col1 of the data frame to plot boxplot of the data points. The labels is assigned as the column header of the data frame. The outcex parameter can be used to assign the size to the outlier.
 "Data Frame" col1 col2 1 a 1 2 b 2 3 a 3 4 a 4 5 b 5 6 a 12  6