Skip to content
Back to formatted view

Raw Message

Message-ID: <A1BF9A54-A156-4B1E-A730-0093B0CAD613@comcast.net>
Date: 2009-03-24T03:20:47Z
From: David Winsemius
Subject: Properly labeling abline with text?
In-Reply-To: <938003.17487.qm@web56003.mail.re3.yahoo.com>

?rect

--  
David Winsemius
On Mar 23, 2009, at 11:01 PM, Jason Rupert wrote:

>
> The result of the code shown below is posted at the following URL:
> http://n2.nabble.com/Trying-to-properly-label-abline-td2524629.html
>
> I would like to figure out a better way to label the horizontal  
> abline.
>
> I tried multiplying the text y position by a scale, but this didn't  
> always put the text in a useful position.   I guess I am curious if  
> there is a preferred procedure for labeling the abline.  Is there a  
> way to "fill" the text label and also put a box around the text  
> label?  I guess I would also like to have the box around the text  
> match the abline format.
>
> Thank you for any info or insights.
>
>
> x_vals<-1:1000
> y_vals<-rnorm(1000)
>
> plot(x_vals, y_vals)
>
> top_label<-paste("Top Label = ", format(max(y_vals), digits=2),  
> sep="")
> abline(h=max(y_vals), col="darkred")
> text(max(x_vals), max(y_vals), top_label, pos=2)
>
> bottom_label<-paste("Bottom Label = ", format(min(y_vals),digits=2),  
> sep="")
> abline(h=min(y_vals), col="darkred")
> text(max(x_vals), min(y_vals), bottom_label, pos=2)
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT