我正在以下图的顶部寻找一个图例,它描述了框架中的多边形和蓝点。
require(lattice)
grid<-data.frame(F=rnorm(1000),T=rep(c("A","B"),each=500))
histogram(~F|T, data=grid, params=c(1,2)
,layout=c(2,1), xlab = "",ylab="",as.table=TRUE
#,par.settings = list(superpose.polygons = list(col=c(4)))
#,key = list(polygons = list(col=c(4)),space="top",columns=1
# ,text = list("text")
# )
#, auto.key = list(polygons = TRUE,title = "Survived", columns = 1)
,type="density",breaks=40
,panel=function(x,params,...){
panel.grid()
panel.histogram(x,...,col=8)
lab<-format(params[panel.number()], digits=2, nsmall=2)
panel.points(params[panel.number()],0,pch=16,col=4)
panel.text(1, 0.05, labels = lab)
})