[R] modifying sound package function plot.Sample

David Winsemius dwinsemius at comcast.net
Sat Jun 20 13:48:06 CEST 2009


On Jun 20, 2009, at 7:05 AM, rajesh j wrote:

> Hi,
> I'm trying to modify this function.I want to remove the existing  
> xaxis(the
> tick marks and the values below each tick) and make it dynamic so  
> that i can
> choose whether i want the xaxis at the top or bottom but i cant seem  
> to
> change that.can somebody help me?
>
> plot.Sample <- function(x,xlab=NULL,ylab=NULL,...){
>  sampletest <- is.Sample(x,argname="'x' ")
>  if (!sampletest$test) stop(sampletest$error)
>  s <- loadSample(x,filecheck=FALSE)
>  s <- normalize(s)
>  if (channels(s)==1) {
> #    if (is.null(ylab)) ylab <- "waveform"
>
> plot(sound(s) 
> [1,],type="l",col="black",xlab=xlab,ylab=ylab,axes=FALSE,...)

If I understand you correctly, then try (untested):

plot(sound(s)[1,],type="l",col="black",xlab=xlab,ylab=ylab,  
xaxt="n", ...)

Although I'm not sure you can use that ellipsis in that context.

>
> #    axis(1)
> #    axis(2,at=c(-1,0,1),labels=as.character(c(-1,0,1)))
> #    abline(h=0)
> #    abline(h=c(-1,1))
> #    lines(par()$usr[1:2],y=c(rep(par()$usr[3],2)),xpd=TRUE)

The locator function would let you get user input that could be used  
to drive alternative specifications to the axis() function
>
>
> -- 
> Rajesh.J
>
> 	[[alternative HTML version deleted]]
>

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list