The data is of two forms, ie one numeric and another ordinal ie 1.5 and <.5. The X Value is a factor. I'm trying to create a lattice conditioned plot with the following characteristics: 1) The plot is conditioned using the form (Conductivity~Day|Valve) 2) The plot should use a barplot for the ordinal (<.5) and dots for the numeric (1.5) 3) A line should be created specifying a limit (ie 0.5) What I would like is the bar on Day 3 to be a dot at 0.5 (a red one would be even better) I have the following working: data <- data.frame(Conductivity=c(.24,.24,.5),Day=as.factor(c(1,2,3)),Valve=as.factor(c("60-V-234","60-V-234","60-V-234"))) print(barchart(Conductivity~Day|Valve, data=data, horizontial=FALSE, # type="p", xlab=list(label="Day",cex=3), ylab=list(label=expression(paste("Endotoxin (EU/mL)")),cex=3), ylim=c(0,1), # index.cond=list(c(2,1)), scales=list(x=list(rot=90,cex=2),y=list(cex=2)) ,panel=function (x,y,...) { panel.barchart(x,y,...) panel.abline(h=0.25,col="red") } # main="Stable Pressure for 70-DS-005 Protocol 02-634-02B" ) ) Any thoughts? I know it's something simple, I just cannot see it... Thanks in advance. ------------------------------------------------------------------------------- Shawn Way 14 Cambridge Center Cambridge, MA 02142 Ph:617-679-4488 [[alternative HTML version deleted]]
On 12/15/05, Shawn Way <Shawn.Way at biogenidec.com> wrote:> The data is of two forms, ie one numeric and another ordinal ie 1.5 and > <.5. The X Value is a factor. > > I'm trying to create a lattice conditioned plot with the following > characteristics: > > 1) The plot is conditioned using the form (Conductivity~Day|Valve) > 2) The plot should use a barplot for the ordinal (<.5) and dots for the > numeric (1.5) > 3) A line should be created specifying a limit (ie 0.5) > > What I would like is the bar on Day 3 to be a dot at 0.5 (a red one would > be even better) > > > I have the following working: > > data <- > data.frame(Conductivity=c(.24,.24,.5),Day=as.factor(c(1,2,3)),Valve=as.factor(c("60-V-234","60-V-234","60-V-234"))) > > print(barchart(Conductivity~Day|Valve, > data=data, > horizontial=FALSE, > # type="p", > xlab=list(label="Day",cex=3), > ylab=list(label=expression(paste("Endotoxin (EU/mL)")),cex=3), > ylim=c(0,1), > # index.cond=list(c(2,1)), > scales=list(x=list(rot=90,cex=2),y=list(cex=2)) > ,panel=function (x,y,...) { > panel.barchart(x,y,...) > panel.abline(h=0.25,col="red") > } > # main="Stable Pressure for 70-DS-005 Protocol 02-634-02B" > ) > )You seem to have used a cutoff of 0.25 (rather than 0.5) in your example.> Any thoughts? I know it's something simple, I just cannot see it...How about panel=function (x, y, ...) { below <- y < 0.25 if (any(below)) panel.barchart(x[below], y[below], ...) if (any(!below)) panel.xyplot(x[!below], y[!below], ..., col = 'red', cex = 2, pch = 16) panel.abline(h=0.25,col="red") } ? Deepayan -- http://www.stat.wisc.edu/~deepayan/
I have read multiple books and looked at many posts online and can't seem to figure out how to add a 1:1 line in lattice xyplot. I've tried multiple versions of getting this to work, including trying "panel.abline(h=0,v=1), panel=function and others. Second question, how do I get the legend created via "auto.key" to use the "pch=c(15,16,17,18) and associated colors, these are circle, square,triangle and diamond, but the auto.key just plots points with different default colors, not the grey scales and symbols that the actual plots uses, how do I get these to match. Is auto.key not the way to go, again I read on many different methods, but no luck yet. Thanks, Ian xyplot(Inv591$RichTOL~gbm_tol$fitted, data=Inv591,group=EcoRegion, main"Observed vs Predicted for RichTOL (BRT development model)",xlab="Observed RichTOL", ylab="Predicted RichTOL", xlim= c(2,8), ylim= c(2,8), pch=c(15,16,17,18), cex=1.1, col=c('grey10','grey30','grey60','grey80'),cex.lab=1.8, cex.axis=1.8,font=2, auto.key=list(corner=c(1,0)), panel=function(x,y){ panel.xyplot(x,y) panel.abline(lm(Inv591$RichTOL~gbm_tol$fitted)) -- View this message in context: http://r.789695.n4.nabble.com/Lattice-graphics-with-combined-plot-types-tp790070p4641486.html Sent from the R help mailing list archive at Nabble.com.