Hello,I am using xyplot to try and create a conditional plot. Below is a toy example of the type of data I am working with slevel <- rep(rep(c(0.5,0.9), each=2, times=2), times=2) tlevel <- rep(rep(c(0.5,0.9), each=4), times=2) noutliers <- rep(rep(c(2,4), times=4), times=2) analysis <- as.factor(rep(c('uv', 'mv'), each=8)) cp <- c(0.9450,0.9525,0.9425,1.0000,0.9425,0.9410,0.900,0.800,0.9050,0.9020, 0.9040,0.9140,0.9400,0.9430,1.000,0.800 ) area <- c(2.896485,4.952239,2.899030, 7.522729,2.827712, 4.950359,3.651156, 4.966610,2.85710, 6.649610 ,2.212295,2.778280,1.897921, 2.847249,1.777387, 2.418103) xyplot(cp ~ noutliers|slevel*tlevel, group=analysis, cex=area, type='o', ylab="", col=c("red","blue"), xlab='', ) This creates a trellis plot with four panels and four points in each panel. I want the size of the points in each panel to be proportional to the value of area (simply putting cex=area in the xyplot function obviously isn't working). I assume that I must create a customized panel function but haven't had any luck. Any suggestions would be appreciated. Garrritt [[alternative HTML version deleted]]
On Thu, May 14, 2009 at 12:14 PM, Garritt Page <page2990 at gmail.com> wrote:> Hello,I am using xyplot to try and create a conditional plot. ?Below is a > toy example of the type of data I am working with > > slevel <- rep(rep(c(0.5,0.9), each=2, times=2), times=2) > > tlevel <- rep(rep(c(0.5,0.9), each=4), times=2) > > noutliers <- rep(rep(c(2,4), times=4), times=2) > > analysis <- as.factor(rep(c('uv', 'mv'), each=8)) > > > cp <- c(0.9450,0.9525,0.9425,1.0000,0.9425,0.9410,0.900,0.800,0.9050,0.9020, > 0.9040,0.9140,0.9400,0.9430,1.000,0.800 ) > > > area <- c(2.896485,4.952239,2.899030, 7.522729,2.827712, 4.950359,3.651156, > 4.966610,2.85710, 6.649610 ,2.212295,2.778280,1.897921, ?2.847249,1.777387, > 2.418103) > > > > xyplot(cp ?~ noutliers|slevel*tlevel, group=analysis, cex=area, > > type='o', ylab="", col=c("red","blue"), > > xlab='', > > > > ) > > This creates a trellis plot with four panels and four points in each panel. > ?I want the size of the points in each panel to be proportional to the value > of area (simply putting cex=area in the xyplot function obviously isn't > working). ?I assume that I must create a customized panel function but > haven't had any luck. ?Any suggestions would be appreciated.Take a look at the example in ?level.colors; you just need to modify it to work with cex instead of color. -Deepayan
On Thu, May 14, 2009 at 2:14 PM, Garritt Page <page2990 at gmail.com> wrote:> Hello,I am using xyplot to try and create a conditional plot. ?Below is a > toy example of the type of data I am working with > > slevel <- rep(rep(c(0.5,0.9), each=2, times=2), times=2) > > tlevel <- rep(rep(c(0.5,0.9), each=4), times=2) > > noutliers <- rep(rep(c(2,4), times=4), times=2) > > analysis <- as.factor(rep(c('uv', 'mv'), each=8)) > > > cp <- c(0.9450,0.9525,0.9425,1.0000,0.9425,0.9410,0.900,0.800,0.9050,0.9020, > 0.9040,0.9140,0.9400,0.9430,1.000,0.800 ) > > > area <- c(2.896485,4.952239,2.899030, 7.522729,2.827712, 4.950359,3.651156, > 4.966610,2.85710, 6.649610 ,2.212295,2.778280,1.897921, ?2.847249,1.777387, > 2.418103) > > > > xyplot(cp ?~ noutliers|slevel*tlevel, group=analysis, cex=area, > > type='o', ylab="", col=c("red","blue"), > > xlab='', > > > > ) > > This creates a trellis plot with four panels and four points in each panel. > ?I want the size of the points in each panel to be proportional to the value > of area (simply putting cex=area in the xyplot function obviously isn't > working). ?I assume that I must create a customized panel function but > haven't had any luck. ?Any suggestions would be appreciated.This is pretty easy to do in ggplot2: library(ggplot2) qplot(noutliers, cp, colour=analysis, size=area, facets = slevel ~ tlevel) + geom_line(size = 0.5) Hadley -- http://had.co.nz/