text command - how to get a white background to cover grid lines

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

text command - how to get a white background to cover grid lines

Henry
New to R - rookie question.
I'm a mechanical engineer and enjoying using R to make high quality graphs.

I've searched.

I want to put text notation on graph plot areas and have the text background "box" white to cover over the grid lines.

my command so far....
text(15,5200,"Air Flow",cex=.8,col="blue", background="white") # this doesn't work...

I've tried bg="white", background color="white" and a number of other attempts.

The text is getting placed on the chart where I want it.

Thanks,
-Henry
Reply | Threaded
Open this post in threaded view
|

Re: text command - how to get a white background to cover grid lines

Pete Brecknock
How about using the legend function ...

plot(rnorm(100))
legend(60,2,"100 Random Normal Draws",cex=.8,text.col="blue", box.col="red",bg="yellow")

You can customize my effort to fit your specific needs

HTH

Pete

Henry wrote
New to R - rookie question.
I'm a mechanical engineer and enjoying using R to make high quality graphs.

I've searched.

I want to put text notation on graph plot areas and have the text background "box" white to cover over the grid lines.

my command so far....
text(15,5200,"Air Flow",cex=.8,col="blue", background="white") # this doesn't work...

I've tried bg="white", background color="white" and a number of other attempts.

The text is getting placed on the chart where I want it.

Thanks,
-Henry
Reply | Threaded
Open this post in threaded view
|

Re: text command - how to get a white background to cover grid lines

Jim Lemon
In reply to this post by Henry
On 02/06/2012 08:23 AM, Henry wrote:

> New to R - rookie question.
> I'm a mechanical engineer and enjoying using R to make high quality graphs.
>
> I've searched.
>
> I want to put text notation on graph plot areas and have the text background
> "box" white to cover over the grid lines.
>
> my command so far....
> text(15,5200,"Air Flow",cex=.8,col="blue", background="white") # this
> doesn't work...
>
> I've tried bg="white", background color="white" and a number of other
> attempts.
>
> The text is getting placed on the chart where I want it.
>
Hi Henry,
have a look at the boxed.labels function in the plotrix package.

Jim

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: text command - how to get a white background to cover grid lines

glsnow
An alternative is the shadowtext function in the TeachingDemos package.

On Mon, Feb 6, 2012 at 1:19 AM, Jim Lemon <[hidden email]> wrote:

> On 02/06/2012 08:23 AM, Henry wrote:
>>
>> New to R - rookie question.
>> I'm a mechanical engineer and enjoying using R to make high quality
>> graphs.
>>
>> I've searched.
>>
>> I want to put text notation on graph plot areas and have the text
>> background
>> "box" white to cover over the grid lines.
>>
>> my command so far....
>> text(15,5200,"Air Flow",cex=.8,col="blue", background="white") # this
>> doesn't work...
>>
>> I've tried bg="white", background color="white" and a number of other
>> attempts.
>>
>> The text is getting placed on the chart where I want it.
>>
> Hi Henry,
> have a look at the boxed.labels function in the plotrix package.
>
> Jim
>
>
> ______________________________________________
> [hidden email] 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.



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: text command - how to get a white background to cover grid lines

lwaldron
For posterity, I found the TeachingDemos::shadowtext option most
agreeable for this problem:

    * legend puts a large box around the text which did not seem
possible to shrink, and does not accept vector x, y arguments
    * plotrix::boxed.labels did not work with pos=4 (this moved the
text, but not the box)
    * TeachingDemos::shadowtext puts an opaque "shadow" around the
text, rather than a box, which obscures a minimum of background while
still making the labels readable. col="black", bg="white" options
produced this effect (default options are opposite this).

On Mon, Feb 6, 2012 at 10:56 PM, <[hidden email]> wrote:

>
> An alternative is the shadowtext function in the TeachingDemos package.
>
> On Mon, Feb 6, 2012 at 1:19 AM, Jim Lemon <[hidden email]> wrote:
> > On 02/06/2012 08:23 AM, Henry wrote:
> >>
> >> New to R - rookie question.
> >> I'm a mechanical engineer and enjoying using R to make high quality
> >> graphs.
> >>
> >> I've searched.
> >>
> >> I want to put text notation on graph plot areas and have the text
> >> background
> >> "box" white to cover over the grid lines.
> >>
> >> my command so far....
> >> text(15,5200,"Air Flow",cex=.8,col="blue", background="white") # this
> >> doesn't work...
> >>
> >> I've tried bg="white", background color="white" and a number of other
> >> attempts.
> >>
> >> The text is getting placed on the chart where I want it.
> >>
> > Hi Henry,
> > have a look at the boxed.labels function in the plotrix package.
> >
> > Jim
> >
> >
> > ______________________________________________
> > [hidden email] 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.
>
>
>
> --
> Gregory (Greg) L. Snow Ph.D.
> [hidden email]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: text command - how to get a white background to cover grid lines

Jim Lemon
On 09/07/2012 07:30 AM, Levi Waldron wrote:
> For posterity, I found the TeachingDemos::shadowtext option most
> agreeable for this problem:
>
>      * legend puts a large box around the text which did not seem
> possible to shrink, and does not accept vector x, y arguments
>      * plotrix::boxed.labels did not work with pos=4 (this moved the
> text, but not the box)

True, boxed.labels just passes arguments such as "pos" to the "text"
function. You probably want something like:

boxed.labels(15,5200,"Air Flow",bg="white",border=NA)

>      * TeachingDemos::shadowtext puts an opaque "shadow" around the
> text, rather than a box, which obscures a minimum of background while
> still making the labels readable. col="black", bg="white" options
> produced this effect (default options are opposite this).
>
However, shadowtext does the job just as well.

Jim

______________________________________________
[hidden email] 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.