[R] modifying sound package function plot.Sample

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Jun 20 17:33:54 CEST 2009


Change as in:

plot.Sample <- function(......., xaxloc = 1){
....

and in the body replace "axis(1)" by "axis(xaxloc)"

then you can call plot(....., xaxloc=3) in order to plot the xaxis at 
the top (while bottom is still the default).

Uwe Ligges






David Winsemius wrote:
> 
> 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
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list