I'm doing a fairly straightforward xyplot lattice graph, using both points and a line connecting them for clarity. However, in some of my panels, data is sparse and I don't want to connect the points. I want to be able to specify which panels should have a line. I've tried using par.settings and panel.superpose, but I must be missing something because nothing is quite working. When I tried panel.superpose, it seems to nullify all my other graphical settings that aren't in that statement. I've found answers on how to change line types for different groups within one panel, but I want them to be different between panels and I'm stumped.
Here's the code:
theme1 <-list(strip.background=list(col="gray75"))
myplot=xyplot(Average.of.response~bin|disttype,
groups=X_LEVEL_,
data=initbehav.disttype[order(initbehav.disttype$disttype),],
subset=initbehav=="Foraging",
par.settings = theme1,
ylab=list(label="Average Probability of Response Type",cex=1.1, fontface="bold"),
xlab=list(label="Distance to Disturbance Source (m)", cex=1.2, fontface="bold"),
key=list(text=list(
lab=as.character(unique(initbehav.disttype$X_LEVEL_)),
padding.text=10),
points=list(cex=1.5, pch=c(0,16,2,18), col="black"),
columns=4,
space="bottom"),
type=c("l","p"),
pch=c(0,16,2,18),
cex=1.4,
col="black",
scales=list(
x=list(rot=45, cex=0.9),
y=list(cex=1.1)
)
)
EDITED with sample data:
For argument's sake, if this was my code:
group=(c("a","b","c"))
data=data.frame(
Y=runif(30,min=0, max=25),
X=rep(c("dog", "car", "person"), each=10),
Z=sample(group, 30, replace=T))
library(lattice)
xyplot(Y~X|Z,
data=data,
type=c("smooth","p"),
cex=1.4,
col="black",
scales=list(
x=list(rot=45, cex=0.9),
y=list(cex=1.1)
)
)
And I want to remove the smooth line from JUST the "dogs" panel, while leaving everything else intact, how would I use a custom panel function to achieve that? Can I still keep arguments that I wish to apply to every panel outside of the custom panel function?