[R] Putting a text box in a plot

Sergey Goriatchev sergeyg at gmail.com
Mon Sep 21 12:26:29 CEST 2009


Here is a kind of example:

plot(density(rnorm(1000)))
text(c(2,2),c(0.2,0.21),labels=c("Skewness","Kurtosis"), pos=4, cex=0.7)
text(c(3,3),c(0.2, 0.21), labels=c(1.1, 2.2), pos=4, cex=0.7)

There is a function in some library that produces text boxes (with
borders) that can be placed inside a plot.
That is what I need - a bordered box containing text inside a plot. So
legend() and mtext() do not apply here, and text() is just too raw.
There is a special function for that, as I say. I once asked on an R
forum, and somebody directed me to this function. Unfortunately, I am
not successful googling that question of mine. It's been a few years.

Best,
Sergey


On Mon, Sep 21, 2009 at 12:13, baptiste auguie
<baptiste.auguie at googlemail.com> wrote:
> Where do you want this text to be placed then?
>
> maybe a call to legend(), or mtext() would suffice, it's hard to say
> more without a reproducible example.
>
>
> baptiste
>
>
>
> 2009/9/21 Sergey Goriatchev <sergeyg at gmail.com>:
>> Hi, Baptiste
>>
>> Yes, I've found textplot() function, but I doubt it is the one I need.
>> What I have is a density plot, and I want to add to this density plot
>> a text box containing the stats I mentioned in previous email.
>> I could do that kind of stuff with simple text() function, but then
>> everytime x values change I will have to change x-axis output
>> coordinates in text() function.
>> No, there must be another function somewhere that produces these text boxes.
>>
>> Best,
>> Sergey
>>
>> On Mon, Sep 21, 2009 at 11:49, baptiste auguie
>> <baptiste.auguie at googlemail.com> wrote:
>>> Hi,
>>>
>>> Maybe the textplot() function in the gplots package?
>>>
>>> HTH,
>>>
>>> baptiste
>>>
>>> 2009/9/21 Sergey Goriatchev <sergeyg at gmail.com>:
>>>> Hello everyone,
>>>>
>>>> I have a plot and I want to but a (formatted) box containing text and
>>>> numbers, say:
>>>> Mean: 0.1
>>>> St.Deviation: 1.1
>>>> Skewness: 1.1
>>>> Kurtosis: 0.5
>>>>
>>>> I know there is a way to do this, there is a function in some library,
>>>> but it's been years since
>>>> I used this function, and I do not remember where I found it.
>>>> Could anyone help out?
>>>>
>>>> Thank you in advance!
>>>> Sergey
>>>>
>>>> --
>>>> Kniven skärpes bara mot stenen.
>>>>
>>>> ______________________________________________
>>>> 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.
>>>>
>>>
>>
>>
>>
>> --
>> I'm not young enough to know everything. /Oscar Wilde
>> Experience is one thing you can't get for nothing. /Oscar Wilde
>> When you are finished changing, you're finished. /Benjamin Franklin
>> Tell me and I forget, teach me and I remember, involve me and I learn.
>> /Benjamin Franklin
>> Luck is where preparation meets opportunity. /George Patten
>>
>> Kniven skärpes bara mot stenen.
>>
>



-- 
I'm not young enough to know everything. /Oscar Wilde
Experience is one thing you can't get for nothing. /Oscar Wilde
When you are finished changing, you're finished. /Benjamin Franklin
Tell me and I forget, teach me and I remember, involve me and I learn.
/Benjamin Franklin
Luck is where preparation meets opportunity. /George Patten

Kniven skärpes bara mot stenen.




More information about the R-help mailing list