Skip to content

Mtext and xyplot

2 messages · Yang, Richard, Deepayan Sarkar

#
Dear all;

I wish to create a graphic object combing an xyplot() and an mtext(). My
code looks like following,

gmv <-  {
         trellis.device("windows", bg="white", width = 7, height = 7)
         
  xyplot(Mvol  ~ Age | Nl * Th , data = Hft1, 
  
  prepanel = function(x, y) prepanel.loess(x, y, span = 1),
        xlab =list(label = "Age (Years)", font = 2),
        ylab = " ", 
#        ylab = list(expression(paste("Volume ( ", paste(m^3/ha, ")"), sep=
" ")), font=2),
         main = list(" Volume"),
         par.strip.text = list(cex=1.0, font = 2),
       panel = function(x, y)  {
         panel.grid ()
         panel.xyplot(x,y, col= "black")
         panel.lmline(x, y, lty = 2, lwd = 2) 
         panel.loess(x, y, span = 1, degree = 1, lty=1, lwd=2) } )
         mtext(expression(paste("Volume ( ", paste(m^3/ha, ")"), sep = "
")), outer=T,
font = 2, side = 2, line = -1 )
         }

The mtext() is to replace the ylab because the font = 2 in the above
commented line does not result in a bold font as in the xlab. The code
within the outmost { } works fine on a windows device  but generates error
when it runs as a function:

Error in mtext(expression(paste("Volume ( ", paste(m^3/ha, ")"),  : 
        plot.new has not been called yet

Any suggestions to rectify the error?

TIA,

Richard
#
On Monday 03 February 2003 03:47 pm, Yang, Richard wrote:
You cannot. xyplot() uses grid for all its graphics, and grid graphics cannot 
be used in conjunction with base R graphics functions.
And it does inside mtext ? (I don't see that on Linux, maybe it does on 
Windows.)
maybe something like 

  ylab = list(expression(bold("Volume...

(read ?plotmath)