Skip to content
Prev 306053 / 398506 Next

efficient overlapping average curve on original curves

HI,

Similar graph in xyplot:
set.seed(1)

mat <- matrix(rnorm(100*37), ncol = 37)
mat <- apply(mat, 2, cumsum)
mat1<-melt(mat)


library(latticeExtra)
p0<-xyplot(value~X1,group=X2,data=mat1,type="l",ylab="mat1")
p1<-xyplot(aggregate(mat1,list(mat1$X1),function(x) mean(x))[,4]~X1,data=mat1,type="l",col="black",lwd=2)
p0+p1

A.K.



----- Original Message -----
From: Rui Barradas <ruipbarradas at sapo.pt>
To: eliza botto <eliza_botto at hotmail.com>
Cc: "r-help at r-project.org" <r-help at r-project.org>
Sent: Friday, September 21, 2012 7:33 PM
Subject: Re: [R] efficient overlapping average curve on original curves

Hello,

Something like this?


# Make up some data
mat <- matrix(rnorm(100*37), ncol = 37)
mat <- apply(mat, 2, cumsum)
avg <- rowMeans(mat)

# matplot - matrix plot
matplot(mat, type = "l")
lines(avg, lwd = 2)


I've also seen some very nice graphics for ploting many lines in ggplot2 
using transparency in order to give a visual picture of where there are 
more lines.

Hope this helps,

Rui Barradas
Em 22-09-2012 00:11, eliza botto escreveu:
______________________________________________
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.