[R] how to make multiple curves in one plot

Joshua Wiley jwiley.psych at gmail.com
Tue Nov 2 08:16:02 CET 2010

Hi Karena,

As Remko mentioned, it really is polite to say what package your
function is from if its not one of the basics (such as base or stats).
 Also, it is nice to give us sample data (side note, both of these
things are mentioned in the posting guide which you may find here:

In any case I was able to search and find what is most likyle the
function you are using.  Although it does not make particular sense,
here is an example plot with two sets of different lines added.  They
incorporate results from running(), although the general plot() and
lines() function do not really care where the x and y values came

dat <- runif(100)
plot(dat, running(dat, width = 5, pad = TRUE))
lines(dat, running(dat, width=10, fun = median, pad = TRUE))
lines(dat, running(dat, width=10, fun = mean, pad = TRUE), col = "blue")



On Mon, Nov 1, 2010 at 8:34 PM, karena <dr.jzhou at gmail.com> wrote:
> hello,
> plot(running(-log10(results_chr_p$empi_p), fun=mean, width=41, font.axis=4,
> by=1),type="l",cex=0.1, ylab="-Log(p)", ylim=c(0,5.0), xlab=" ", lwd=2)
> this is my code to make a plot. The problem is, now I want to add one more
> curve to the plot, which is for another variable in the data.frame
> -log10(results_chr_p$p). My question is: how to make multiple lines in one
> plot, especially when using the 'running' function in it??
> thank you very much,
> karena
> --
> View this message in context: http://r.789695.n4.nabble.com/how-to-make-multiple-curves-in-one-plot-tp3023135p3023135.html
> Sent from the R help mailing list archive at Nabble.com.
> ______________________________________________
> 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.

Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles

More information about the R-help mailing list