- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 create a boxplot with outliers of larger size in R?
When we create a boxplot for a column of an R data frame that contains outlying values, the points for those values are smaller in size by default. If we want to increase the size for those outlying points then outlier.size argument can be used inside geom_boxplot function of ggplto2 package.
Consider the below data frame −
Example
set.seed(1231) x<-sample(LETTERS[1:4],20,replace=TRUE) y<-c(rnorm(19,5,1),10) df<-data.frame(x,y) df
output
x y 1 B 5.983562 2 A 4.571819 3 D 6.110019 4 A 4.074785 5 A 6.034136 6 B 5.351433 7 C 4.596340 8 C 3.375895 9 D 4.849060 10 A 4.723585 11 B 5.406556 12 A 6.254387 13 B 6.408786 14 C 5.386244 15 D 4.215608 16 A 4.576638 17 B 5.688985 18 B 3.839879 19 C 5.914120 20 B 10.000000
Loading ggplot2 package and creating boxplots for y values based on categories in x with default size of outliers −
Example
library(ggplot2) ggplot(df,aes(x,y,col=x))+geom_boxplot()
Output
Creating the boxplots with larger size of outlier −
Example
ggplot(df,aes(x,y))+geom_boxplot(outlier.size=5)
Output
- Related Articles
- How to highlight outliers in a boxplot in R?
- How to extract the outliers of a boxplot in R?
- How to hide outliers in base R boxplot?
- How to display outliers in boxplot with different shape in base R?
- How to create a plot in base R with tick marks of larger size?
- How to fill the outliers with different color in base R boxplot?
- How to change the color of outliers in base R boxplot?\n
- How to create a boxplot using ggplot2 with aes_string in R?
- How to create a boxplot with log of the variable in base R?
- How to create transparent boxplot in R?
- How to create a scatterplot with larger distance between facets in R?
- How to create a horizontal boxplot in base R?
- How to create boxplot of grouped data in R?
- How to create a line chart using ggplot2 with larger width in R?
- How to create a boxplot of single column in R data frame with column name?

Advertisements