Dear Jim,
many thanks for your reply and support.
It seems to be that with your help I could solve my problem with the plotting of the data. The only thing that does not work is to see the coloured lines, maybe because of the crowd of curves.
With the density of curves I ment to distinguish in the confidence interval between areas, where a lot of curves (lines) are located, and areas having a lower density of lines. In other words, I would like to show the area, where 100 % of the lines are included, then the area, where 90 % are included, and so forth with the other quantiles, but with a steady change of colours, and not by a stepwise change (if posible).


Many thanks again,
Fred


Jim Lemon wrote:

Fred Hattermann wrote:


Dear R-user,
I am a R beginner, and therefore my questions are very basic.
I have a simple problem: I would like to plot 100 time series each
containing 55 steps. The data are stored in a matrix of 100 columns and
55 rows. The first problem is to load the data from a file: I tried the
read.table(), the scan() and the matrix(scan()) options, but I have
problems to allocate the single columns. The list() option could be a
solution, but it is very unconvenient: list(0,0,0......).



# generate some random numbers testts.df<-data.frame(matrix(rnorm(5500)/5,nrow=55)) # superimpose them on a sine curve newts<-sapply(testts.df,function(x) return(x+sin(seq(0,pi*2,length=55)))) # make it a time series newts<-as.ts(newts) # write out the data write.table(newts,"newts.dat") # read it in again newts<-as.ts(read.table("newts.dat"))



And how do I plot a single time series, let's say the 50s? And how to
plot all of them?



# plot the first one
plot(newts[,1],ylim=range(newts))
# add the other 99 lines - probably pretty messy!
for(i in 2:100) lines(newts[,i])



The last problem is maybe more advanced: I would like to plot all 100
time series, but with a confidence interval, where the density of data
is indicated by the density of the colour of the confidence interval.



# get the means of the observation points newts.means<-apply(as.matrix(newts),1,mean) # calculate a CI - probably not the one you want newts.ci<-1.96*sapply(as.matrix(newts),sd) # plot the CI lines(newts.means+newts.ci,col="red") lines(newts.means-newts.ci,col="green")

I'm not sure what you mean by the "density" of the curve, so I can't suggest anything. However, I am adding a function named "color.scale" to the next version of the "plotrix" package, so I'll email you when I put it up on CRAN.

Jim






--
*******************************************************
* Potsdam Institute for Climate Impact Research (PIK) *
* Telegrafenberg  C 4   D-14473 Potsdam               *
* PO box:  60 12 03     D-14412 Potsdam                *
* Tel.:  (0331) 288 - 2649                            *
* Fax:   (0331) 288 - 2695                            *
* e-mail: [EMAIL PROTECTED]                   *
*******************************************************

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to