- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# How to highlight outliers in a boxplot in R?

To highlight outliers in a boxplot, we can create the boxplot with the help of Boxplot function of car package by defining the id.method.

For example, if we have a vector called V then the boxplot of V with highlighted outliers can be created by using the below given command −

Boxplot(~V,id.method="y")

## Example 1

To highlight outliers in a boxplot, use the command given below −

library(car) x<-c(-10,rnorm(18),10) Boxplot(~x,id.method="y") [1] "1" "20"

## Output

If you execute all the above given snippets as a single program, it generates the following output −

## Example 2

To highlight outliers in a boxplot, use the command given below −

grp<-rep(LETTERS[1:4],each=5) Response<-c(-5,rpois(3,1),10,-8,rpois(3,2),8,-10,rpois(3,2),10,-12,rpois(3,3),12) Boxplot(Response~grp,id.method="y") [1] "1" "5" "6" "10" "11" "15" "16" "20"

## Warning message

In Boxplot.default(mf[[response]], x, id = list(method = id.method, −

NAs introduced by coercion

This warning message is displayed because format of the values might not be proper in Response vector but it does not make an impact on the boxplots so we can ignore it.

## Output

If you execute all the above given snippets as a single program, it generates the following output −

- Related Questions & Answers
- How to hide outliers in base R boxplot?
- How to extract the outliers of a boxplot in R?
- How to create a boxplot with outliers of larger size in R?
- How to change the color of outliers in base R boxplot?
- How to display outliers in boxplot with different shape in base R?
- How to fill the outliers with different color in base R boxplot?
- How to highlight a bar in base R histogram?
- How to highlight a value with underline in base R plot?
- How to create a horizontal boxplot in base R?
- How to create transparent boxplot in R?
- How to show values in boxplot in R?
- How to create a rectangle inside boxplot in base R?
- How to create a boxplot without frame in base R?
- How to remove end lines from a boxplot in R?
- How to display mean inside boxplot created by using boxplot function in R?