Text label buffering

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Text label buffering

Matthew Vavrek
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

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Text label buffering

Sarah Goslee
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
<[hidden email]> 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

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Text label buffering

Johannes Signer
There is also the boxed.labels() function in the plotrix package.

HTH Johannes

On Thu, Jun 23, 2011 at 2:49 PM, Sarah Goslee <[hidden email]> wrote:

> 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
> <[hidden email]> 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
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Text label buffering

Greg Snow-2
In reply to this post by Matthew Vavrek
Look at the shadowtext function in the TeachingDemos package.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[hidden email]
801.408.8111


> -----Original Message-----
> From: [hidden email] [mailto:r-sig-geo-bounces@r-
> project.org] On Behalf Of Matthew Vavrek
> Sent: Thursday, June 23, 2011 12:11 PM
> To: [hidden email]
> Subject: [R-sig-Geo] Text label buffering
>
> 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
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo