R/n_make_panel_first.R

Defines functions make_panel.first

make_panel.first<-function(col1, col2="grey98", style=1, ex=.05){
  panel.first<-function(curosr, sweeps_data){
    usr_yrange<-diff(par("usr")[3:4])*ex
    rg<-curosr$range
    tr<-sweeps_data$y
    trx<-sweeps_data$x
    x<-trx[trx > rg[1] & trx < rg[2] ]
    y<-tr[trx > rg[1] & trx < rg[2] ]
    #points(x,y, col="grey70")
    rect(rg[1],ybottom = min(y),xright = rg[2],ytop = max(y), col=col2, border=F)
    if(style==1){
      arrows(rg[1],max(y)-usr_yrange, rg[1],max(y)+usr_yrange, length = 0, col=col1, lty=3)
      arrows(rg[2],max(y)-usr_yrange, rg[2],max(y)+usr_yrange, length = 0, col=col1, lty=3)
    }else{
      arrows(rg[1],y[which.min(x-rg[1])]-usr_yrange, rg[1],max(y)+usr_yrange, length = 0, col=col1, lty=3)
      arrows(rg[2],y[which.min(rg[2]-x)]-usr_yrange, rg[2],max(y)+usr_yrange, length = 0, col=col1, lty=3)
      #arrows(rg[1],max(y), rg[2],max(y), length = 0, col=col1, lty=3)
      
    }
    
    
    text(x=mean(rg), y=max(y), curosr$name,pos = 3, xpd=T, cex=.8)
    #points(x,y, ty="l")
    
  }
  panel.first
}
tdanker/ephys2 documentation built on Aug. 11, 2019, 12:12 p.m.