Adjusting font size of axis labels in levelplot function in R

Angelo picture Angelo · Apr 24, 2012 · Viewed 13.9k times · Source

I have matrix of 90 by 90 and I am trying to get an array correlation matrix. Using the following command:

pdf('corr.pdf')
data <- read.table("test", header=T) 
z <- cor(data)
levelplot(z)
dev.off() 

I get an image like this and my tags are getting smudged enter image description here

Please give your suggestions to improve the image.

Thank you

Answer

TemplateRex picture TemplateRex · Apr 24, 2012

EDIT: Take the first example from the levelplot manual and change the scales=list(log="e") argument to scales=list(log="e",x=list(cex=.3),y=list(cex=.3)):

x <- seq(pi/4, 5 * pi, length.out = 100)
y <- seq(pi/4, 5 * pi, length.out = 100)
r <- as.vector(sqrt(outer(x^2, y^2, "+")))
grid <- expand.grid(x=x, y=y)
grid$z <- cos(r^2) * exp(-r/(pi^3))
levelplot(z~x*y, grid, cuts = 50, 
      scales=list(log="e",x=list(cex=.3),y=list(cex=.3)), xlab=list(cex=.05),
      ylab=list(cex=.25), main=list(label="Weird Function", cex=5), sub="with log scales",
      colorkey = FALSE, region = TRUE)

This will reduce the axis labels' font sizes with a factor of .3.