How do I show all boxplot labels

user1605665 picture user1605665 · Feb 14, 2013 · Viewed 71.4k times · Source

I've created a box plot, the data on the left is the continous variable and the data on the right has about 10 unique options. When I create the boxplot I cannot see the labels. How do I make it show all the labels, possibly vertically?

boxplot(data$Rate ~ as.factor(data$Purpose))

I've looked around and cannot work out what im trying to follow.

Answer

Didzis Elferts picture Didzis Elferts · Feb 14, 2013

You can add argument las=2 to function boxplot() to make all labels perpendicular to axis.

df<-data.frame(Rate=rnorm(100),Purpose=rep(letters[1:10],each=10))
boxplot(df$Rate~df$Purpose,las=2)

If your label names are long then you should adjust also plot margins.

par(mar=c(7,5,1,1))
boxplot(df$Rate~df$Purpose,las=2)