Skip to content
Prev 32958 / 398506 Next

legend() with option adj=1

On Thu, 5 Jun 2003 07:20:11 -0700
"Anna H. Pryor" <anna at ptolemy.arc.nasa.gov> wrote:

            
. . .
Here is an alternative to consider.  In plots such as this I like to label the curves where they are most separated and avoid legends altogether (as well as usually avoiding the need for different line types, unless curves intertwine):

x <- 1:5
y <- 1/x
y2 <- 2/x
w <- list('1/x'=list(x=x,y=y),'2/x'=list(x=x,y=y2))
library(Hmisc) # see http://hesweb1.med.virginia.edu/biostat/s/Hmisc.html
labcurve(w, pl=TRUE, offset=.1)

Or put a legend in the most empty region of the graph:

labcurve(w, pl=TRUE, lty=c(2,1), lwd=c(1,3), col=gray(c(0,.7)), keys='lines',
         xlab=expression(chi))  
# lty only for demonstration - omit that for this example.  Thick gray scale # lines are excellent for step functions

Or use same line types but put symbols every so often (point.inc= to override default spacing; this works well for overlapping step functions also):

labcurve(w, pl=TRUE, keys=1:2)  # uses pch=1:2

---
Frank E Harrell Jr              Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine  http://hesweb1.med.virginia.edu/biostat