Skip to content

Adding text (coefts) to pairs panels

4 messages · Liaw, Andy, Mark Van De Vyver, Christopher Mahmood

#
You need to figure out the "user coordinates" for each panel, so you can put
the text within the range that's being plotted.  Here's an example:

panel.myfitline <- function(x, y, digits=2, prefix="", cex.cor, ...)
{
    usr <- par("usr")
    res<-panel.smooth(x,y, col.smooth="blue", ...)
    reg <- coef(lm(y ~ x))
    abline(coef=reg,untf=F)
    const<-format(reg[1], trim = FALSE, digits = NULL, nsmall = 0, justify =
"left", ...)
    const<-paste(prefix, const, sep="")
    slope<-format(reg[2], trim = FALSE, digits = NULL, nsmall = 0, justify =
"left", ...)
    slope<-paste(prefix, slope, sep="")
    if(missing(cex.cor)) cex <- 0.8/strwidth(const)
    text(.95*usr[2], usr[3] +.05*(usr[4]-usr[3]), const, cex=cex)
    if(missing(cex.cor)) cex <- 0.8/strwidth(slope)
    text(usr[1] + .1*(usr[2]-usr[1]), .98*usr[4], slope, cex=cex)
}

HTH,
Andy
mailto:mvdv at spamcop.net
http:\\www.econ.usyd.edu.au

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html



------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}
#
Andy,
Thank you very much - that works and shows me how to go about working out
the range of possible values for the position co-ords.
Much appreciated.
Mark
#
Hi, 
The searchable mail archive at http://maths.newcastle.edu.au/~rking/R/ is
very useful.  Unfortunately it seems that many of the emails are not
available, many show up in the search results but then return a "file not
found" when following the link.
Is anyone else experiencing this, and is there an alternative mail archive
with a search facility?
TIA
Mark