1

I'm trying to figure out why plotting a second line on my line graph doesn't work.

My dataset looks something like this:

Time<- c("2011-10-16 09:33","2011-10-16 09:54")
Y1<-c("50259", "41090")
Y2<-c("9823", "98723")

When I plot

plot(Time,Y1,type="l",col="red")

the graph looks fine. But then I add

lines(Time,Y2,col="green")

and nothing registers on the graph. Anyone have any idea why?

Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
LNA
  • 1,427
  • 3
  • 24
  • 37
  • Have a look at [Plotting multiple lines from a data table in R](http://stackoverflow.com/questions/7912180/plotting-multiple-lines-from-a-data-table-in-r) to see if it is useful. – David Alber Oct 29 '11 at 00:50
  • works for me (used `strptime` to convert `X` to `Time`, used `type="l"` rather than `type="1"`) – Ben Bolker Oct 29 '11 at 01:08

1 Answers1

1

I get it to work using the following code. Not sure if this is what you're after:

Time<- as.POSIXct(c("2011-10-16 09:33","2011-10-16 09:54") )
Y1<-c("50259", "41090") 
Y2<-c("9823", "98723") 

plot(Time,as.numeric(Y1),type="l",col="red", ylim=c(9800, 98800))
abline(lm(as.numeric(Y2)~Time),col="green") 
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519