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
Sebastian Luque <sluque at mun.ca> wrote:> I have a 3 panel xyplot with different variables in the y axis. I'm > trying to insert a newline after "Width (cm),"Sorry, that should be "VarC (cm)," in the hypothetical example below! -- Sebastian P. Luque
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 at cirad.fr tel.: +261 32 40 165 53 (cell) +261 20 22 665 36 ext. 225 (work) +261 20 22 494 37 (home)
Seemingly Similar Threads
- How to pass in a list of variables as an argument to a function?
- Automated generation of combinations
- creating a dynamic output vector
- fitting several lme sistematically
- cross-correlation table with subscript or superscript to indicate significant differences