R语言lattice包可以自己定制panel函数。当使用高级函数(例如xyplot,levelplot)绘图时,会调用相应的panel函数来给每个panel(面板)绘图。
最近发现不同的函数传将参数输给面板函数的方式有所不同。
首先来看看xyplot。
library(lattice)
# 这里定义一个简单的panel函数,打印传输进来的变量
myPanel <- function(x, y, subscripts, ...) {
panel.xyplot(x, y, ...)
cat('调用myPanel:\n')
cat('x: ', x, '\n')
cat('y: ', y, '\n')
cat('subscripts: ', subscripts, '\n\n')
}
data <- d