Re: [R] Avoiding overplotting of text.
On Mon, Feb 25, 2008 at 10:36 PM, hadley wickham <[EMAIL PROTECTED]> wrote: > > I am plotting some data, and use text() to get variable names next to > > points on the graph. What is the best way to make sure that these text > > labels are readable and not overlapping when two datapoints are close? > > I've tried using jitter(), but the effect is random and doesn't always > > give a good result. > > Any suggestions would be most appreciated. > > Have a look at pointLabel in maptools - > http://finzi.psych.upenn.edu/R/library/maptools/html/pointLabel.html > > > -- > http://had.co.nz/ > Thank you, Hadley. That was a very good tool to find! In conjunction to the regular tricks mentioned by Rickard Cotton, and thigmophobe by Jim Lemon, the problem turned out to be fairly easy. This seem like one of those tasks that is needed fairly frequently, but which is rarely bothered with. Would it be possible to add one of these algorithms as an option to the regular text()? Regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@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.
Re: [R] Avoiding overplotting of text.
> I am plotting some data, and use text() to get variable names next to > points on the graph. What is the best way to make sure that these text > labels are readable and not overlapping when two datapoints are close? > I've tried using jitter(), but the effect is random and doesn't always > give a good result. > Any suggestions would be most appreciated. Have a look at pointLabel in maptools - http://finzi.psych.upenn.edu/R/library/maptools/html/pointLabel.html -- http://had.co.nz/ __ R-help@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.
Re: [R] Avoiding overplotting of text.
> I am plotting some data, and use text() to get variable names next to > points on the graph. What is the best way to make sure that these text > labels are readable and not overlapping when two datapoints are close? > I've tried using jitter(), but the effect is random and doesn't always > give a good result. It is probably possible to calculate the space that each label takes up on the page, and write some logic to automatically reposition the labels. This however is almost certainly very tricky to do properly. The easier options are: 1. If you only have a few labels, and it's just one or two graphs, manually reposition them. 2. Make the text smaller and/or make the device size larger. 3. Draw the labels in different colours so that they can be distinguished even when they overlap. 4. Don't draw the labels on the plotting region; use a key instead. Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ R-help@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.
Re: [R] Avoiding overplotting of text.
Gustaf Rydevik wrote: > Hi all, > > I am plotting some data, and use text() to get variable names next to > points on the graph. What is the best way to make sure that these text > labels are readable and not overlapping when two datapoints are close? > I've tried using jitter(), but the effect is random and doesn't always > give a good result. > Any suggestions would be most appreciated. > Hi Gustaf, Have a look at thigmophobe.labels in the plotrix package. Jim __ R-help@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.
[R] Avoiding overplotting of text.
Hi all, I am plotting some data, and use text() to get variable names next to points on the graph. What is the best way to make sure that these text labels are readable and not overlapping when two datapoints are close? I've tried using jitter(), but the effect is random and doesn't always give a good result. Any suggestions would be most appreciated. Best regards, Gustaf Example: -- x<-rnorm(20) x.labels<-vector(length=length(x)) for(i in 1:length(x))x.labels[i]<-paste(sample(LETTERS,5,replace=T),collapse="") y<-rnorm(length(x)) plot(x,y) text(x,y,x.labels) ###Most of the time some of the labels end up unreadable. --- -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@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.