mashc
mashc

Reputation: 21

Change size of outlier labels on boxplot in R

I have generated two side by side boxplots and labeled the outliers using the car package in R. While this works well, I dont know how to change the size of the outlier labels. I can change the size of the outlier point, but not the label.

Edit: Here is a subset of my data

gene    low_cov scaffolds
AA001   10  150
AA002   15  20
AA003   2   160
AA004   20  144
AA005   30  122
AA006   1   80
AA007   50  500
AA008   16  200
AA009   18  164
AA010   4   124

Here is my current code:

gene = read.csv(file.choose(), header=T, sep='\t', row.names=1)
library(car)
par(mfrow=c(1,2))
Boxplot(gene$low_cov, data=gene, labels=row.names(gene), cex=0.2)
Boxplot(gene$scaffolds, data=gene, labels=row.names(gene), cex=0.2)
par(mfrow=c(1,1))

Any ideas?

Upvotes: 1

Views: 9348

Answers (2)

Marina Vance
Marina Vance

Reputation: 81

You can change the size of the outlier symbols using "outcex". E.g., "outcex=2"

Upvotes: 5

CT Zhu
CT Zhu

Reputation: 54330

I think you can firstly plot without the outliners, and then manually add them. In that way, you can almost do whatever you want to do to change the style, shape, color, etc. I will use the base function boxplot here:

> data <- c(10,15,2,20,30,1,50,16,18,4)
> B <- boxplot(data, outline=FALSE, ylim=c(0, 55))
> points(B$group, B$out, type = "p", pch=23)

enter image description here

Upvotes: 0

Related Questions