[R] question about "srt" argument in text() plotting function

David Winsemius dwinsemius at comcast.net
Fri Feb 25 23:48:55 CET 2011


On Feb 25, 2011, at 4:28 PM, Carl Witthoft wrote:

>
>
> Just wondering: it appears that "srt" does not accept a vector of  
> values, just a single  value.  I ended up using tapply() as the  
> following code snippet shows, so it's not a major problem.  I was  
> justa little surprised that this argument (srt) differs from things  
> like "labels,"  "lty,"  "col,"  and so on, all of which accept (and  
> recycle as needed IIRC) vectors.
>
> Carl
>
> ******* code follows  *******
>
> dialang<-seq(pi/3,-pi*3/2,by=-pi/6)
>        d2<-as.character(seq(1,12)) # or roll your own hour tags
>        plot(c(-1.2,1.2),c(-1.2,1.2),t='n',xlab='',ylab='',  
> xaxt='n',yaxt='n' )
> #trying a rotation w/ srt()
>        # srt apparently can't handle a vector
>        invisible(sapply(seq(1,12),FUN=function(x)  
> text(cos(dialang[x]),sin(dialang[x]),labels=d2[x],srt=-x*30)))

There is a baseGrid package containing baseViewports() that allows you  
to align a viewport with the plotting region and then do vectorized  
rotation with the angle parameter to viewport()

See:
http://cran.r-project.org/doc/Rnews/Rnews_2003-2.pdf

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list