[R] Add lines to xy plot with temporal x axis

David Winsemius dwinsemius at comcast.net
Fri Aug 26 19:15:45 CEST 2011


On Aug 26, 2011, at 11:35 AM, chirleu wrote:

> Hi. I'm trying to add some vertical lines to an xyplot in which x  
> axis is a
> temporal variable (class=dates) and y axis a factor variable.
>
> This is my code:
>
> xyplot(factor(Abacus$Emisor)~Abacus$Dia,xlab="Date",  
> ylab="Fish",pch=124,
> scales=list(x=list(format="%b %Y",tick.number=30))
> , panel=function(...){
> 		panel.xyplot(...)
> 		panel.abline(v=08/08/2008)
> 	})
>
> I'd expect a vertical line in the date 08/08/2008 but nothing is  
> drawn.
> Also, I tried with an horinzontal line got no result...

Probably because you didn't give panel.abline an argument that could  
be unambiguously converted to a date (even if there were an automatic  
conversion facility in panel abline to do so which I seriously doubt.)  
You seem to have been using a DateTime object for Abacus$Dia,  but why  
are you not also using the data=Abacus formalism?

Given the lack of an example of your data,  it's hard to say much  
more. You could provide str(Abacus) or dput( head(Abacus) ) and get  
much better advice as a result.
>
> Any help please??

It would certainly help _us_ if you would follow requested  
guidelines--->

> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Let's see if furhter emphasis can be added with an R example:
 > toupper("and provide commented, minimal, self-contained,  
reproducible code." )
[1] "AND PROVIDE COMMENTED, MINIMAL, SELF-CONTAINED, REPRODUCIBLE CODE."
-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list