[R-SIG-Finance] plotting vertical lines on months in xyplot

Jeffrey Ryan jeffrey.ryan at lemnica.com
Wed Mar 16 04:11:37 CET 2011


Hi Worik, Jeff,

Try,

abline(v=.index(X)[50], col="red")

Note the "dot" in .index.  The fact is that xts uses the internal
POSIXct(like) time for the x-axis, so you need to access it that way.

HTH
Jeff

On Tue, Mar 15, 2011 at 9:47 PM, Worik <worik.stanton at gmail.com> wrote:
> I have a similar problem as Jeff had back in the day.  I want to put a
> vertical line on a plot
>
> There must be a way....
>
> Simple example:
>
> library(xts)
> v <- vector()
> v[1] <- 10
> for(i in 2:100){
>  v[i] <- v[i-1]+rnorm(1, 0, 0.01)
> }
> X <- xts(v, seq(as.Date("2009-01-01"), by=1, length.out=100))
> plot(X)
>
> ## Try to put a vertical line in....
> abline(v=X[50,])
> abline(v=50)
> abline(v=index(X)[50])
>
>
>
> --
> If we amplify everything, we hear nothing.
> --
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>



-- 
Jeffrey Ryan
jeffrey.ryan at lemnica.com

www.lemnica.com

R/Finance 2011 April 29th and 30th in Chicago
www.RinFinance.com



More information about the R-SIG-Finance mailing list