[R] Plot Many Data to same plot
R. Michael Weylandt
michael.weylandt at gmail.com
Tue Feb 21 14:06:41 CET 2012
What do you want to change about the lines? pch (different characters)
might give the desired variety.
Michael
On Tue, Feb 21, 2012 at 7:56 AM, Alaios <alaios at yahoo.com> wrote:
> Dear all,
> I have a function that for a variable number of inputs plots them to the same plot
> I am doing this quite simply by
>
> plot(seq(from=start, to=stop, length.out=np), datalist[[1]]$dataset
> xlim=c(start, stop), ylim=c(0, 1), type="l")
>
> if (length(datalist) > 1) {
> for (i in 2:length(datalist)) {
> np <- length(datalist[[i]]$dataset)
> lines(seq(from=start, to=stop, length.out=np), datalist[[i]]$dataset$, lty=i)
> }
> }
>
> as you can see, specifically this line
>
> lines(seq(from=start, to=stop, length.out=np), datalist[[i]]$dataset$ lty=i)
>
> is changing the line type so any different input is plotted with different line type.
>
> This works quite well for 6 lines but if the arguments are more than 6 (in my case 7) the line type starts from the beginning. Is it possible to keep that loop and have the lines produced in plots a bit more customized (like lines with squares and or cubes).
>
> I have already checked in the ?par
> but I can not find how I can modify the line in that sense, and especially doing this smart inside a for loop.
>
>
> Could you please help me with that?
> I would like to thank you in advance for your help
>
> Regards
> Alex
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list