0

我的数据大多集中在一个小范围内,但有很多点超出了这个范围。我想为这些数据绘制一个直方图,该直方图将侧重于小范围,但也会显示异常值。与这篇文章相比,直方图的对数刻度之类的东西

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)
         }

)
4

0 回答 0