Displaying 1 result from an estimated 1 matches for "h2d".
Did you mean:
2d
2006 Feb 06
2
panel.levelplot() for 2D histograms
...ta.frame(x=rnorm(3000),y=rnorm(3000),group=rep(factor(c("A","B","C")),
1000))
# this binscatter-function shows what I want,
# I just would like to have it as a panel function
binscatter<-function(x,y){
col<-rev(gray.colors(5))
breaks=c(1,5,10,100,500,100000)
h2d<-hist2d(x=x,y=y,nbins=10,same.scale=T,show=F)
image(h2d$x,h2d$y,h2d$counts,breaks=breaks,col=col,axes=T)
}
# for one group, this works fine
A<-subset(ds,group=="A")
binscatter(A$x,A$y)
# simple xyplot does too (of course)
xyplot(y~x|group,data=ds)
# but my lattice-ified version...