[R] boxplot - code for labeling outliers - any suggestions for improvements?
Jim Lemon
jim at bitwrit.com.au
Fri Jan 28 10:37:28 CET 2011
On 01/28/2011 07:57 AM, Greg Snow wrote:
> Try:
>
> library(TeachingDemos)
>
> plot(Sepal.Length~Sepal.Width, data=iris)
>
> tmp.y<- iris$Sepal.Length
> for( i in unique(iris$Sepal.Width) ) {
> tmp<- iris$Sepal.Width == i
> tmp.y[ tmp ]<- spread.labs( tmp.y[tmp], .6*strheight('A'),
> maxiter=1000 )
> }
>
> # optional
> with(iris, segments(Sepal.Width, Sepal.Length, Sepal.Width+0.025, tmp.y) )
>
> with(iris, text(Sepal.Width+0.05, tmp.y, seq_along(tmp.y), cex=.5 ) )
>
>
> There is also thigmophobe.labels in the plotrix package which is simpler and works well for some plots
>
Alas, I tried thigmophobe.labels and there are just too many points.
The best I could do was this:
irisxy<-cluster.overplot(iris$Sepal.Width,iris$Sepal.Length)
plot(irisxy)
text(irisxy$x,irisxy$y-0.04,labels=1:150,cex=0.5)
which, sad to say, ain't too good.
Jim
More information about the R-help
mailing list