I have written code which puts text to the upper right of points on a plot. Some of my point are very close together and the new text is writing over the previous text. Has anyone written a clever "smart-text" function that writes the text in a blank spot near the point (perhaps on the lower left or lower right side) when it discovers that the new space is not blank. I could write such a function if there was an is.blank(x,y) command. Does something like that exist? Thanks.
See ?emptyspace in the plotrix package. On Tue, Jan 13, 2009 at 5:02 PM, John Fort <jfort at bio.fsu.edu> wrote:> I have written code which puts text to the upper right of points on a plot. > Some of my point are very close together and the new text is writing over > the previous text. > > Has anyone written a clever "smart-text" function that writes the text in a > blank spot near the point (perhaps on the lower left or lower right side) > when it discovers that the new space is not blank. > > I could write such a function if there was an is.blank(x,y) command. Does > something like that exist? > > Thanks. > > ______________________________________________ > 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. >
John Fort wrote:> I have written code which puts text to the upper right of points on > a plot. Some of my point are very close together and the new text is > writing over the previous text. > > Has anyone written a clever "smart-text" function that writes the > text in a blank spot near the point (perhaps on the lower left or > lower right side) when it discovers that the new space is not blank. > > I could write such a function if there was an is.blank(x,y) command. > Does something like that exist?Hi John, Have a look at thigmophobe.labels in the plotrix package. That package also contains the emptyspace function that tries to find the largest empty space in a plot. There is an even snazzier empty space function, but I keep forgetting which package it is in... Jim
Jim Lemon <jim <at> bitwrit.com.au> writes:> There is an even snazzier empty space function, > but I keep forgetting which package it is in... > > JimpointLabel, in the maptools package (by Tom Short), uses simulated annealing or a genetic algorithm to try to find optimal text placements. Ben Bolker