Kristiina Hurme
2010-Apr-23 03:06 UTC
[R] help with plotting lines linking two sets of points?
Hello everyone, I'm trying to plot the initial and final size of some tadpoles and look at their growth rates (slope of line). They are divided into 6 densities, and so far I have plotted the initial and final sizes (these are means for a pool), and color coded for the 6 densities, but I want a line to connect the initial and final value for each pool (also color coded by density). Any ideas? I'm hoping to see what the effect of density is on growth, and there are 4 replicates for each density. The initial and final sizes are staggered, 1/2 were measured at age 7.3 and 11, and the other 1/2 were measured at age 8.5 and 12. here's a sample pool age age2 density body_length body_length2 1 1 7.4 11.3 25 0.887 1.322550 2 2 7.4 11.3 100 0.921 1.152000 3 3 7.4 11.3 250 0.896 1.136300 4 4 7.4 11.3 75 0.723 0.955950 5 5 7.4 11.3 500 0.755 1.113300 6 6 7.4 11.3 50 0.869 1.169833 and as far as i've gotten> plot(age,body_length,pch=as.numeric(school), col=as.numeric(density), > xlim=c(6,13), ylim=c(0.7,1.6)) > points(age2, body_length2, pch=as.numeric(school), > col=as.numeric(density))http://n4.nabble.com/forum/FileDownload.jtp?type=n&id=2023096&name=Screen_shot_2010-04-22_at_11.03.08_PM.png thanks! kristiina -- View this message in context: http://r.789695.n4.nabble.com/help-with-plotting-lines-linking-two-sets-of-points-tp2023096p2023096.html Sent from the R help mailing list archive at Nabble.com.
Dennis Murphy
2010-Apr-23 14:02 UTC
[R] help with plotting lines linking two sets of points?
Hi: Does this work for you? df <- read.table(textConnection(" pool age age2 density body_length body_length2 1 1 7.4 11.3 25 0.887 1.322550 2 2 7.4 11.3 100 0.921 1.152000 3 3 7.4 11.3 250 0.896 1.136300 4 4 7.4 11.3 75 0.723 0.955950 5 5 7.4 11.3 500 0.755 1.113300 6 6 7.4 11.3 50 0.869 1.169833"), header = TRUE) closeAllConnections() with(df, plot(age,body_length, pch=as.numeric(pool), col=as.numeric(density), xlim=c(6,13), ylim=c(0.7,1.6))) with(df, points(age2, body_length2, pch=as.numeric(pool), col=as.numeric(density))) with(df, segments(age, body_length, age2, body_length2, col as.numeric(density))) HTH, Dennis On Thu, Apr 22, 2010 at 8:06 PM, Kristiina Hurme <kristiina.hurme@uconn.edu>wrote:> > Hello everyone, > I'm trying to plot the initial and final size of some tadpoles and look at > their growth rates (slope of line). They are divided into 6 densities, and > so far I have plotted the initial and final sizes (these are means for a > pool), and color coded for the 6 densities, but I want a line to connect > the > initial and final value for each pool (also color coded by density). Any > ideas? > I'm hoping to see what the effect of density is on growth, and there are 4 > replicates for each density. The initial and final sizes are staggered, 1/2 > were measured at age 7.3 and 11, and the other 1/2 were measured at age 8.5 > and 12. > > here's a sample > > pool age age2 density body_length body_length2 > 1 1 7.4 11.3 25 0.887 1.322550 > 2 2 7.4 11.3 100 0.921 1.152000 > 3 3 7.4 11.3 250 0.896 1.136300 > 4 4 7.4 11.3 75 0.723 0.955950 > 5 5 7.4 11.3 500 0.755 1.113300 > 6 6 7.4 11.3 50 0.869 1.169833 > > and as far as i've gotten > > plot(age,body_length,pch=as.numeric(school), col=as.numeric(density), > > xlim=c(6,13), ylim=c(0.7,1.6)) > > points(age2, body_length2, pch=as.numeric(school), > > col=as.numeric(density)) > > > http://n4.nabble.com/forum/FileDownload.jtp?type=n&id=2023096&name=Screen_shot_2010-04-22_at_11.03.08_PM.png > > thanks! kristiina > > -- > View this message in context: > http://r.789695.n4.nabble.com/help-with-plotting-lines-linking-two-sets-of-points-tp2023096p2023096.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >[[alternative HTML version deleted]]