我的数据主要集中在一个小范围内,但有大量的点超出此范围。我想为这些数据绘制直方图,该数据将集中在小范围,但也会显示异常值。类似于直方图的对数比例,与此post
相比较require(latticeExtra)
n<-1000
m<-matrix(c(rnorm(n,240,56),rnorm(n,47,13),rnorm(n,23,7),rnorm(n,8.7,3)),nrow=n)
m<-rbind(m, matrix(c(rnorm(n,385,78), rnorm(n,160,32), rnorm(n,4,.8), rnorm(n,.6,.12)), nrow=n))
grid<-data.frame(ev=m,model=rep(c("A","B"),each=n))
histogram(~c(ev.1,ev.2,ev.3,ev.4)|model
,data=grid
,layout=c(2,1), xlab = "",ylab=""
,type=c("density")
#,par.settings = list(superpose.polygon=list(alpha=c(.5,.5,.5,.5)))
,panel=function(x,subscripts=subscripts,...){
panel.grid()
x<-matrix(x,nrow=n)
panel.histogram(x[,1],...,col=4,alpha=.5)
panel.histogram(x[,2],...,col=2,alpha=.5)
panel.histogram(x[,3],...,col=5,alpha=.5)
panel.histogram(x[,4],...,col=7,alpha=.5)
}
)