Re: [R] lattice, add text to xyplot

2010-01-08 Thread Ivan Gregoretti
Thank you. It works.

Ivan

Ivan Gregoretti, PhD
National Institute of Diabetes and Digestive and Kidney Diseases
National Institutes of Health
5 Memorial Dr, Building 5, Room 205.
Bethesda, MD 20892. USA.



On Fri, Jan 8, 2010 at 8:13 PM, David Winsemius  wrote:
>
> On Jan 8, 2010, at 8:10 PM, Jason Morgan wrote:
>
>> On 2010.01.08 19:44:39, Ivan Gregoretti wrote:
>>>
>>> Hello listers,
>>>
>>> Does anybody know how to add text to an xyplot without whipping out
>>> the existing curve?
>>> That's all.
>>>
>>> For instance,
>>>
>>> Lets say you generate a graph like this
>>>
>>> A <- data.frame(x = rnorm(100), y = rnorm(100))
>>> xyplot(y ~ x, data = A)
>>>
>>> How would you add 'Hello world'?
>>>
>>> I tried 6.02E23 different partial solutions found on the web and
>>> failed. I just need one EXAMPLE that WORKS.
>>>
>>> Unfortunately,
>>>
>>> library(lattice)
>>> ?panel.text
>>>
>>> shows no examples.
>>>
>>> As you see, I bring you a formidable challenge.
>>
>> A <- data.frame(x = rnorm(100), y = rnorm(100))
>> xyplot(y ~ x, data = A,
>>      panel = function(...) {
>>        panel.text(0, 0, "Hello world!")
>>        panel.xyplot(...)
>>      })
>
> Or, following a Sarkar r-helpful example on how to add to an existing plot:
>
>  library(lattice)
>  A <- data.frame(x = rnorm(100), y = rnorm(100))
>  xyplot(y ~ x, data = A)
>  trellis.focus("toplevel") ## has coordinate system [0,1] x [0,1]
>  panel.text(0.5, 0.2, "Hello, world", cex = 1.2, font = 2)
>  trellis.unfocus()
>
> --
> David
>>
>> A whole lot of examples lattice are available here:
>>
>> http://lmdvr.r-forge.r-project.org/figures/figures.html
>>
>> If you plan on using lattice often, I highly recommend Deepayan Sarkar's
>> book.
>>
>> Hope that helps,
>> ~Jason
>>
>>>
>>> Thank you,
>>>
>>> Ivan
>>>
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>

__
R-help@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.


Re: [R] lattice, add text to xyplot

2010-01-08 Thread David Winsemius


On Jan 8, 2010, at 8:10 PM, Jason Morgan wrote:


On 2010.01.08 19:44:39, Ivan Gregoretti wrote:

Hello listers,

Does anybody know how to add text to an xyplot without whipping out
the existing curve?
That's all.

For instance,

Lets say you generate a graph like this

A <- data.frame(x = rnorm(100), y = rnorm(100))
xyplot(y ~ x, data = A)

How would you add 'Hello world'?

I tried 6.02E23 different partial solutions found on the web and
failed. I just need one EXAMPLE that WORKS.

Unfortunately,

library(lattice)
?panel.text

shows no examples.

As you see, I bring you a formidable challenge.


A <- data.frame(x = rnorm(100), y = rnorm(100))
xyplot(y ~ x, data = A,
  panel = function(...) {
panel.text(0, 0, "Hello world!")
panel.xyplot(...)
  })


Or, following a Sarkar r-helpful example on how to add to an existing  
plot:


 library(lattice)
 A <- data.frame(x = rnorm(100), y = rnorm(100))
 xyplot(y ~ x, data = A)
 trellis.focus("toplevel") ## has coordinate system [0,1] x [0,1]
 panel.text(0.5, 0.2, "Hello, world", cex = 1.2, font = 2)
 trellis.unfocus()

--
David


A whole lot of examples lattice are available here:

http://lmdvr.r-forge.r-project.org/figures/figures.html

If you plan on using lattice often, I highly recommend Deepayan  
Sarkar's

book.

Hope that helps,
~Jason



Thank you,

Ivan



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@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.


Re: [R] lattice, add text to xyplot

2010-01-08 Thread Jason Morgan
On 2010.01.08 19:44:39, Ivan Gregoretti wrote:
> Hello listers,
> 
> Does anybody know how to add text to an xyplot without whipping out
> the existing curve?
> That's all.
> 
> For instance,
> 
> Lets say you generate a graph like this
> 
> A <- data.frame(x = rnorm(100), y = rnorm(100))
> xyplot(y ~ x, data = A)
> 
> How would you add 'Hello world'?
> 
> I tried 6.02E23 different partial solutions found on the web and
> failed. I just need one EXAMPLE that WORKS.
> 
> Unfortunately,
> 
> library(lattice)
> ?panel.text
> 
> shows no examples.
> 
> As you see, I bring you a formidable challenge.

A <- data.frame(x = rnorm(100), y = rnorm(100))
xyplot(y ~ x, data = A,
   panel = function(...) {
 panel.text(0, 0, "Hello world!")
 panel.xyplot(...)
   })

A whole lot of examples lattice are available here:

http://lmdvr.r-forge.r-project.org/figures/figures.html

If you plan on using lattice often, I highly recommend Deepayan Sarkar's
book.

Hope that helps,
~Jason

> 
> Thank you,
> 
> Ivan
> 
> Ivan Gregoretti, PhD
> National Institute of Diabetes and Digestive and Kidney Diseases
> National Institutes of Health
> 5 Memorial Dr, Building 5, Room 205.
> Bethesda, MD 20892. USA.

-- 
Jason W. Morgan
Graduate Student
Department of Political Science
*The Ohio State University*
154 North Oval Mall
Columbus, Ohio 43210

__
R-help@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.