R/erp.xaxis.R

# this function is basically a wrapper for axis with msectopoints embedded and with some little additional features.
# for finer tuning use directly axis (see also par).

erp.xaxis <- function (length.erp = NULL, startmsec=NULL, endmsec = NULL, x.tick=NULL, x.labels = x.tick,  x.las=0, draw.x.ticks=TRUE, x.pos = NA,  x.outer = FALSE, x.font = NA, x.lty = "solid", x.lwd = 1, x.lwd.ticks = 1, x.col = NULL, x.col.ticks = NULL, x.hadj = NA, x.padj = NA, x.tcl = -0.5, x.tick.both= FALSE, x.cex = 1)
{
  
  if (is.null(length.erp)){
    stop("the length of the erp waveform need to be specified.\n The axis is drawn taking into account this length and the two parameters starmsec and endmsec", call.=F)
  }
  
  if (is.null(startmsec)|is.null(endmsec)){
    stop("startmsec and endmsec must be specified", call.=F)
  }
  
  if (is.null(x.tick)){
    x.tick=seq(startmsec, endmsec, 200)
  }
  
  # tick and labels positions
  ticksandlab=msectopoints(x.tick, length.erp, startmsec, endmsec)
  
  axis(1, at= ticksandlab, labels=x.labels, pos= x.pos, tick = draw.x.ticks , outer = x.outer, font = x.font, lty = x.lty, lwd = x.lwd, lwd.ticks = x.lwd.ticks, col = x.col, col.ticks = x.col.ticks, hadj =, x.hadj, padj = x.padj, tcl = x.tcl, cex.axis = x.cex, las=x.las)
  
  if (x.tick.both==TRUE){
    axis(1, at= ticksandlab, labels= FALSE, pos= x.pos, tick = draw.x.ticks, outer = x.outer, font = x.font, lty = x.lty, lwd = x.lwd, lwd.ticks = x.lwd.ticks, col = x.col, col.ticks = x.col.ticks, tcl = - x.tcl, las=x.las) # NOTICE the minus in tcl: it is for plotting in the other direction
    
  }
  
  
}

Try the erpR package in your browser

Any scripts or data that you put into this service are public.

erpR documentation built on June 7, 2019, 3 a.m.