One of the reasons we ask for a *reproducible* example, is that it allows us to test our ideas and make sure that all the details are taken care of. Here's a reproducible example that may help solve your problem:
lx100=c(1,1,1,.8,.5,.4,.2,0) day100=c(0,1,2,3,4,5,6,7) lx90=c(1,1,1,1,.9,.8,.6,.4,.2,.1,0) day90=c(0,1,2,3,4,5,6,7,8,9,10) lx0=c(1,1,1,1,1,1,.9,.9,.8,.8,.6,.5,.4,.3,.2,.1,.1,0) day0=c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17) lx = list(lx0=lx0,lx90=lx90,lx100=lx100) day = list(day0=day0,day90=day90,day100=day100) plot(range(unlist(day)),range(unlist(lx)), type="n", xlab="Day of adult life",ylab='lx',lwd=2.2) mapply(function(x,y,col)points(x,y,type='b',col=col),day,lx,rainbow(length(lx))) legend('topright',names(lx),pch=1,lty=1,col=rainbow(length(lx))) title('Survival vs. Time') - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Sun, 29 Nov 2009, Frostygoat wrote:
I have 11 vectors representing insect survival probabilities in response to different levels of toxins at 10 concentrations lx100=c(1,1,1,.8,.5,.4,.2,0) day100=c(0,1,2,3,4,5,6,7,8) lx90=c(1,1,1,1,.9,.8,.6,.4,.2,.1,0) day90=c(0,1,2,3,4,5,6,7,8,9,10) #...and so on10% and a zero (control) series lx0=c(1,1,1,1,1,1,.9,.9,.8,.8,.6,.5,.4,.3,.2,.1,.1,0) day0=c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17) I want to plot them on one plot with a palette color scheme such as rainbow or topo.colors, and I want one color per concentration on both the point and line. I have found a number of ways to plot them: 1. Plot a blank frame big enough to accommodate the control data and then add the x,y coords using points. plot(x=day0,y=lx0, type="n", xlab="Day of adult life",ylab=lx,lwd=2.2,ylim=c(0.0,1),col=cols) points(x=day100,y=lx100,type="b",col="#FF8B00") points(x=day90,y=lx90,type="b",col= "#E8FF00") ... This is harder than it should be, I tracked down the color names generated with rainbow(11) and individually name each points command. 2. Bind the respective x and y coords into 2 respective matrices and plot. lxs=matrix(c(lx100,lx90,lx80,lx70,lx60...)) days=matrix(c(day100,day90,day80,day70,day60...)) plot(x=days,y=lxs, col=rainbow(11), type="b") The points rainbow (not as series) and the lines are red. I tried various methods of binding data and plotting data frames without success. I would appreciate it if someone would kindly put me on the trail. Thank you for your time. ______________________________________________ R-help@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.
______________________________________________ R-help@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.