[R] Alignment when rotating text and symbols

p.b.pynsent p.b.pynsent at bham.ac.uk
Tue Jul 29 11:04:28 CEST 2003


I wanted to annotate some points on lines, above and below the lines.  
I thought the easiest way would be to use text() and two pos values.
However I found when the text was rotated the space and alignment 
between the point and the text did not remain constant. The following 
code illustrates the problem:
x <- c(0,10.)
y <- c(0,10.)
offset <- 3
centre <- 5
plot(x,y, xlim=range(x), ylim=range(y),type="n", xlab="",ylab="", 
main="",xaxt="n",yaxt="n")
for (i in (seq(0, 340, by=45))	)
	{
	px <- centre + cos((i*pi)/180) * offset
	py <- centre + sin((i*pi)/180) * offset
	text(px, py,
	labels=substitute(that%->%phantom(1),list(that=i)), pos=1, col="blue", 
cex=0.7, srt=i)
	text(px, py,
	labels=substitute(that%<-%phantom(1),list(that=i)), pos=3, 
col="blue",cex=0.7,srt=i)
	lines(px, py, type="p", col="black") #just for reference
	}
What have I done wrong?
In addition, on my screen, the arrow symbols do not rotate at all 
although they do on the pdf image.
(R version 1.71,  MacOS X 10.2.6)

Many thanks.
Paul

Dr. P. B. Pynsent,
Research and Teaching Centre,
Royal Orthopaedic Hospital,
Birmingham, B31 2AP, U.K.




More information about the R-help mailing list