Tuesday, July 14, 2015

How to rotate labels from horizontal to vertical position in R

In R sometimes your labels may not be visible, and you would need to make them vertical to fit in the graph.

E.g. here is one plot that does not fit all the labels.

par(mfrow=c(1,2))
boxplot(GWAS,ylim=c(0,3.5))
boxplot(CAD,ylim=c(0,3.5))


To make the labels visible use las=2 to plot them vertically.
par(mfrow=c(1,2))
boxplot(GWAS,ylim=c(0,3.5),las=2)
boxplot(CAD,ylim=c(0,3.5),las=2)



However, not all the labels are visible here as well.
To make the labels more visible set the margins using mar:

par(mfrow=c(1,2))
par(mar=c(7,5,1,1))
boxplot(GWAS,ylim=c(0,3.5),las=2)

boxplot(CAD,ylim=c(0,3.5),las=2) 

No comments:

Post a Comment