[R] setHook and lattice

Jim Price price_ja at hotmail.com
Fri Feb 29 19:05:10 CET 2008


Hi,

I am trying to find a way to automate production of page numbers in plots
produced using the lattice package. To do this, I started playing around
with setHook which works fine with vanilla plot, but the hook 'plot.new'
doesn't appear to be relevant to the lattice package. I was wondering if
there is a alternative someone can suggest for use with the lattice package. 

Example code:

library(lattice)
graphics.off()


myFunc <- function()
{	
	mainTitle <<- 'Page 1'
}


setHook('plot.new', NULL, 'replace')
setHook('plot.new', myFunc)


mainTitle <- 'No hook called'
plot(1:10, main = mainTitle)


win.graph()
mainTitle <- 'No hook called'
xyplot(1:10 ~ 1:10, main = mainTitle)


setHook('plot.new', NULL, 'replace')




> sessionInfo()
R version 2.6.0 (2007-10-03) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] lattice_0.16-5

loaded via a namespace (and not attached):
[1] grid_2.6.0

-- 
View this message in context: http://www.nabble.com/setHook-and-lattice-tp15764144p15764144.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list