Hi Anna,

I guess it happened because the range of datas[1:n, 2] differs from the
range of datas[1:n, 3]. A workaround would be either to use the maplot()
function as follows or figuring out their ranges and then plug them in as
the ylim argument in the plot call.

Here is a suggestion using matplot()

matplot(datas[1:n,1], cbind(datas[1:n, 2:3]), type="l", main = "SP500 Prices
and Moving
Averages", xlab = "Date", ylab = "Prices",col = c("black","green"), lty = 1)

See ?matplot for details.

And for what you had before:

plot(datas[1:n,1],datas[1:n,2],type="l",main="SP500 Prices and Moving
Averages",xlab="Date",ylab="Prices",col="black",
ylim = c( min(datas[1:n, 2], datas[1:n, 3]), max(datas[1:n, 2], datas[1:n,
3])))
lines(datas[1:n,1],datas[1:n,3],type="l",col="green",lty="solid")

HTH,
Jorge


On Fri, Nov 20, 2009 at 1:56 PM, anna_l <> wrote:

>
> Hello, I am trying to plot a graphic with many lines with the following
> command:
>
> plot(datas[1:n,1],datas[1:n,2],type="l",main="SP500 Prices and Moving
> Averages",xlab="Date",ylab="Prices",col="black")
> lines(datas[1:n,1],datas[1:n,3],type="l",col="green",lty="solid")
>
> But I just see the first curve. I have tried it on the console separately
> and it´s still not working. There is no error message but I can´t see the
> second curve. Is there a parameter that I need to change with par()?
> Thank you
>
> -----
> Anna Lippel
> new in R so be careful I should be asking a loooooooot of questions!:teeth:
> --
> View this message in context:
> http://old.nabble.com/Problem-at-adding-lines-on-a-graphics-with-lines%28%29-function-tp26443627p26443627.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]


