[R] Change the color of the line inside of the function lines

2013-09-16 Thread Arnaud Michel
Hi I have the following problem : I have 3 vectors xx, yy, zz : xx - c(5479, 6209, 6940, 7670, 8766, 9496, 10227, 11048, 11778, 12509, 13239, 13970, 14700, 15340, 15948) yy - c( 267, 275, 281, 287, 296, 306, 316, 325, 334, 351, 365, 377, 389, 419, 419) zz - c( 3, 3, 3, 3, 4, 4, 4, 4,

Re: [R] Change the color of the line inside of the function lines

2013-09-16 Thread Tsjerk Wassenaar
Hi Michel, lines(xx,yy,col=zz-2,type=s) If you use a color vector, say cols, then you can also do lines(xx,yy,col=cols[zz-2],type=s) Hope it helps, Tsjerk On Mon, Sep 16, 2013 at 8:42 AM, Arnaud Michel michel.arn...@cirad.frwrote: Hi I have the following problem : I have 3 vectors xx,

Re: [R] Change the color of the line inside of the function lines

2013-09-16 Thread Arnaud Michel
Hi Tsjerk Thank you but the color always remains black ! I would want that the color changes on the same graph (color = 3 on the 4 first steps, col = 4 on 5 following steps Michel Le 16/09/2013 09:01, Tsjerk Wassenaar a écrit : Hi Michel, lines(xx,yy,col=zz-2,type=s) If you use a

Re: [R] Change the color of the line inside of the function lines

2013-09-16 Thread Tsjerk Wassenaar
Hi Michel, In that case, you need to use segments: ?segments For a line, it works like: plot(xx,yy,type=n) segments(xx[-1],yy[-1],xx[-length(xx)],yy[-length(yy)],col=zz,lwd=2) For a step function, you'll have to do a bit more work :) Cheers, Tsjerk On Mon, Sep 16, 2013 at 9:20 AM, Arnaud

Re: [R] Change the color of the line inside of the function lines

2013-09-16 Thread Pascal Oettli
Hi, Maybe the following might help you: s - seq(length(xx)-1) plot(xx, yy, type=n) segments(xx[s], yy[s], xx[s+1], yy[s], col=zz, lwd=2) segments(xx[s+1], yy[s], xx[s+1], yy[s+1], col='grey') Regards, Pascal On 16/09/2013 15:42, Arnaud Michel wrote: Hi I have the following problem : I

Re: [R] Change the color of the line inside of the function lines

2013-09-16 Thread Arnaud Michel
Thanks Pascal and Tsjerk Michel Le 16/09/2013 09:42, Pascal Oettli a écrit : Hi, Maybe the following might help you: s - seq(length(xx)-1) plot(xx, yy, type=n) segments(xx[s], yy[s], xx[s+1], yy[s], col=zz, lwd=2) segments(xx[s+1], yy[s], xx[s+1], yy[s+1], col='grey') Regards, Pascal On