Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the size of label values in xyplot in R

Tags:

r

lattice

I'm using xyplot in R to plot several lines (by group) on one graph:

xyplot(y~x,
       type=c('l'),
       scales=list(tck=c(1,0)),
       main=list(label="Total decrease", cex=2),
       xlab=list(label="Years", cex=1.5),
       ylab=list(label="Percentage", cex=1.5),
       groups= group,
       data=df,
       auto.key=list(columns=2, lines=TRUE, points=FALSE, cex=1.5))

However, I am unable to change the size of the label values. I have tried changing the argument cex.axis (within the xlab and ylab options), but this does not change the size of values along either the x- or the y-axes.

Can anybody help?

Thanks in advance, Mark

like image 773
user3628889 Avatar asked May 12 '14 14:05

user3628889


1 Answers

With lattice plotting functions, use scales=list(cex=1.5) to set cex for tick labels along both axes.

To specify different cex values for x- and y- axes, do something like this:

library(lattice)
xyplot(mpg~disp, data=mtcars, 
       scales=list(tck=c(1,0), x=list(cex=1.2), y=list(cex=1.5)))

enter image description here

like image 95
Josh O'Brien Avatar answered Sep 28 '22 14:09

Josh O'Brien