Skip to content
Back to formatted view

Raw Message

Message-ID: <CAAmySGOado0cP2x1tphQS+vj0BzKUiuJ+7ZJxH--jph5CPe4jA@mail.gmail.com>
Date: 2012-02-21T13:06:41Z
From: R. Michael Weylandt
Subject: Plot Many Data to same plot
In-Reply-To: <1329829013.19753.YahooMailNeo@web120106.mail.ne1.yahoo.com>

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.
>