[R-sig-Geo] Text label buffering

Matthew Vavrek matthew at matthewvavrek.com
Thu Jun 23 20:10:42 CEST 2011


Hello all,
I'm making up some maps in R, but some of the labels are being obscured 
by other lines on the map. I'd like to be able to buffer my labels, so 
that there's a bit of whitespace surrounding each letter to make them 
more readable. I've tried doing this by doing a double call to text(), 
with white in bold (font=2) and then a regular font, and by adjusting 
the text size, but the text doesn't really match up between the two 
labels this way.

for example:

par(bg='black')
plot.new()
text(0.5, 0.5, label='text', col='white', font=2, cex=3)
text(0.5, 0.5, label='text', col='black', font=1, cex=3)

or:

par(bg='black')
plot.new()
text(0.5, 0.5, label='text', col='white', cex=3)
text(0.5, 0.5, label='text', col='black', cex=2.9)

give the idea of what I want, but not quite as cleanly as I'd like.

Is there some way of doing this? Seems like there should be, but 
searching the internets hasn't turned up anything yet.

Thanks
Matthew



More information about the R-sig-Geo mailing list