[R] efficient overlapping average curve on original curves

Rui Barradas ruipbarradas at sapo.pt
Sat Sep 22 01:33:05 CEST 2012


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:
> Dear useRs,
>
> my question could be very basic for which i apologize in advance.
> Each column of a matrix with dimensions 365 rows and 37 columns was drawn against another matrix of dimensions 365 rows and 1 column. with that i was able to draw 37 curves on the same axis.
> now i want to draw an average curve of these 37 curves on the same axis in such a way that all the curves (average and 37 curves) should appear on the same axis at the same time.
> i used
>
>> par(new=TRUE)
> But it has 2 limitations
>
> 1- it completly distorted y-axis values
> 2- it was not very efficient as average curve in no overlapped the original curves.
>
> can any1 advise me what to do?
> thanks in advance for you time.
>
> eliza botto
>
>   		 	   		
> 	[[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