[R] newline in lattice axis label

Sebastian Luque sluque at mun.ca
Thu Apr 7 07:01:13 CEST 2005


Hi,

I have a 3 panel xyplot with different variables in the y axis. I'm trying
to insert a newline after "Width (cm)," in the ylab argument as in the
example below. My goal is to have the y axis label broken into two lines,
split after the string just mentioned.

plotfun <- function() {
  fakedf <- data.frame(A = sample(1:100, 50),
                       B = rnorm(50),
                       C = rnorm(50),
                       D = rnorm(50))
  myplot <- xyplot(B + C + D ~ A, data = fakedf,
                   outer = TRUE, allow.multiple = TRUE, layout = c(1,3),
                   ylab = list(expression(paste(
                       "VarB (cm" ^2, "), VarC (cm),\n or VarD (cm)"))),
                   xlab = list("VarA (d)"))
  postscript("testfig.eps")
  print(myplot)
  dev.off()
}

As you can see, this is not producing the desired result, which is
probably associated with 3 warnings:

Warning messages: 
1: font metrics unknown for character 10 
2: font metrics unknown for character 10 
3: font metrics unknown for character 10 

Any help defining the ylab argument in this case is greatly appreciated.

Thanks in advance,
-- 
Sebastian P. Luque




More information about the R-help mailing list