[R] using text() to write into left margin

Ross Ihaka ihaka at stat.auckland.ac.nz
Sat May 8 00:09:56 CEST 1999



On Fri, 7 May 1999, Terry J. Westley wrote:

> In version 0.63.0 for Win95, I can use text() to
> write into the left margin (to the left of the axis)
> as follows:
> 
> > plot(0:10,0:10,pch="+")
> > text(c(1,0.5,0,-0.5,-1),1,"O")
> 
> I see 5 "O" symbols at the expected position, two of
> which are left of the left axis.
> 
> However, in version 0.64.0 for Solaris 2.5.1 on a
> Sparc/Ultra2, I only see three "O" symbols.  Those
> that are to the left of the axis do not appear.
> 
> Is this an expected result?

This is due differences in clipping strategies.  If possible, graphics
primitives are supposed to clip their items to the plot window, but
hardware (and sofware) differs in its ability to do this.  If you want to
turn the clipping off use the "xpd = TRUE" option.

> plot(0:10,0:10,pch="+")
> text(c(1,0.5,0,-0.5,-1),1,"O", xpd = TRUE)
 
> I am using text() instead of mtext() because I want
> the labels to appear at Y co-ordinate positions as
> normal text, not rotated 90 deg.  These are text
> labels rather than numbers, so I'm suppressing the
> left axis and using text() to write the labels.

You could try using the "srt" (string rotation) and "adj" (text
adjustment) options to mtext.  Using
	 mtext(..., srt = 0, adj = 1)
will produce unrotated strings with the text right adjusted.

These options have probably not been exercised as much as some
of the others and may have the odd bug.  If you find any, we'll
fix them.

	Ross

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list