R-beta: plot annotation

Thomas Lumley thomas at biostat.washington.edu
Thu May 21 22:19:02 CEST 1998

On Thu, 21 May 1998, Bill Simpson wrote:

> I have a bunch of curves on a plot and I would like to label each curve.
> Currently, if I place the text right on the curve it is hard to read
> because the text and the curve overlap.  I would like to make a label
> on an opaque white box just slightly larger than the label, and this sits
> on top of the curve. (This is easy to do in drawing programs on the Mac)
> If I have the label ||
> and the line ----------------
> I want the result to look like
> ----||-----
> not like
> ----H------

I would have expected legend() to be able to do this, but it can't -- if
a box is not drawn the background is not shaded.  However you can do it

Suppose s<-"||" is your text, and lx,ly are the coordinates where you want


This draws a rectangle big enough for the text in the current background
color and then writes the text.  You can adjust how much space there is
by changing the 2 to something smaller

Thomas Lumley
Biostatistics		: "Never attribute to malice what  :
Uni of Washington	:  can be adequately explained by  :
Box 357232		:  incompetence" - Hanlon's Razor  :
Seattle WA 98195-7232	:				   :

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