[R-sig-Geo] Text label buffering

Sarah Goslee sarah.goslee at gmail.com
Thu Jun 23 20:49:31 CEST 2011


I would just use rect() to draw a white rectangle, then put the text
on top of it. Trying to frame each letter just seems like too much
work.

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

Sarah

On Thu, Jun 23, 2011 at 2:10 PM, Matthew Vavrek
<matthew at matthewvavrek.com> wrote:
> 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
>



-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-sig-Geo mailing list