Re: [R] newline in lattice axis label

From: Renaud Lancelot <renaud.lancelot_at_cirad.fr>
Date: Thu 07 Apr 2005 - 15:35:23 EST

Sebastian Luque a écrit :

> 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,

library(lattice)
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 = expression(atop(paste("VarB (", cm^2, "), VarC (cm)"),
                           "VarD (cm)")),
                    xlab = "VarA (d)")

   postscript("testfig.eps")
   print(myplot)
   dev.off()
}

plotfun()

Best,

Renaud

-- 
Dr Renaud Lancelot, vétérinaire
C/0 Ambassade de France - SCAC
BP 834 Antananarivo 101 - Madagascar

e-mail: renaud.lancelot@cirad.fr
tel.:   +261 32 40 165 53 (cell)
         +261 20 22 665 36 ext. 225 (work)
         +261 20 22 494 37 (home)

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Thu Apr 07 15:39:27 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:03 EST