Skip to content
Prev 255772 / 398506 Next

lattice: how to "center" a subtitle?

On Apr 4, 2011, at 1:27 PM, Marius Hofert wrote:

            
I _did_ have plotmath functions in both rows: But here is your solution:

xyplot(0 ~ 0,  xlab =
     expression( atop(paste(alpha==1, "   ", beta==2), bold(bla) )) )
       )

Note that `paste` in plotmath is different than `paste` in regular R.  
It has no `sep` argument. I did try both substitute and bquote on you  
externally expression,  but lattice seems to be doing some non- 
standard evaluation and I never got it to "work". Using what I thought  
_should_ work, does work with `plot`:

 > x=1;y=2
 > plot(0 ~ 0, xlab = bquote( atop(alpha==.(x)*","~beta==.(y),  
bold(foo) ) )
+ )

But the same expression throws an error with xyplot:
 > x=1;y=2
 > xyplot(0 ~ 0, xlab = bquote( atop(alpha==.(x)*","~beta==.(y),  
bold(foo) ) )
+ )
Error in trellis.skeleton(formula = 0 ~ 0, cond = list(1L), aspect =  
"fill",  :
   could not find function "atop"