[R] Alignment when rotating text and symbols

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Jul 29 14:04:00 CEST 2003


On Tue, 29 Jul 2003, p.b.pynsent wrote:

> Dear Prof Ripley,
> Many thanks for this response. I do not understand how your example 
> addresses my problem. Basically what concerns me is the relationship 
> between pos=1 and pos=3 upon rotation, if I take your example and 
> modify it slightly to be at srt=180 I would expect to get an inverted 
> view of srt=0.
> This is not the case, the spacing between the two lines of text becomes 
> so different that at 180 degrees the text now fits within the non 
> rotated text. At intermediate values the text remains aligned to the 
> vertical of the plot rather than to the angle of rotation and so 
> becomes offset.
> 
> What I had hoped for was what I get with srt=0, rotated as whole so it 
> looked the same but was just rotated to the specified angle.

But you got what is documented, and my example addessed that.

> 
> plot(1:10, type="n")
> text(5,5, "a bit of text", pos=1)
> text(5,5, "a bit of text", pos=3)
> text(5,5, "a bit of text", pos=1, srt=180)
> text(5,5, "a bit of text", pos=3, srt=180)
> 
> Paul
> 
> On Tuesday, July 29, 2003, at 11:26  am, Prof Brian Ripley wrote:
> 
> > On Tue, 29 Jul 2003, p.b.pynsent wrote:
> >
> >> 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:
> >
> > You are rotating the text about its centre, but pos is not in the
> > rotated frame, as I read it, so why should this be rotation-invariant?
> >
> > Try
> >
> >> plot(1:10, type="n")
> >> text(5,5, "a bit of text")
> >> text(5,5, "a bit of text", pos=1)
> >> text(5,5, "a bit of text", pos=1, srt=45)
> >
> > to see the effect of pos and srt.  You go down then rotate, not rotate 
> > and
> > then go down.
> >
> >> 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)
> >
> > *WHICH* Mac port of R?  There are two!
> >
> > The lack of rotation is a limitation of the (unspecified) graphics 
> > device
> > of your (unspecified) port, whichever it is: it works on Linux and
> > Windows, for example, so I would expect this to work on an X11 device 
> > on
> > the Darwin port.
> >
> Yes this is ambiguous,sorry.  Not the Darwin port.
> > -- 
> > Brian D. Ripley,                  ripley at stats.ox.ac.uk
> > Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> > University of Oxford,             Tel:  +44 1865 272861 (self)
> > 1 South Parks Road,                     +44 1865 272866 (PA)
> > Oxford OX1 3TG, UK                Fax:  +44 1865 272595
> >
> >
> 
> 

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list