I have produced a filled contourplot using contourplot function in the Lattice package. I would like to be able to emphasise one of the contour lines produced by this function, e.g. by changing lwd=2, and de-emphasise the other contour lines produced, e.g. by setting changing the remaining contour line colours to grey.
For example, I would like the equivalent of adding
contourplot(
Male ~ Year * Age,
data=this.ds, region=F, labels=F, lwd=2, at=c(0, 0.01, 1))
To
contourplot(
Male ~ Year * Age,
data=this.ds,
region=T, col.regions=rev(heat.colors(200)),
cuts=50, main="", sep="")
I recognise that the answer is likely to involve the functions update, panel, and/or layer (if using latticeExtra), but I my understanding of the underlying logic/structure of lattice objects is not good enough to figure out what to do.
Edit
Thanks for your help. I basically used the first answer, but with the following slight modification to be able to point out a couple of features on the contour line:
require(lattice)
require(latticeExtra)
Part1 <- contourplot(Female ~ Year * Age,
data=this.ds,
region=T,
col.regions=rev(heat.colors(200)),
cuts=50,
main="",
labels=F,
col="grey",
sep="")
Part2 <- contourplot(Female ~ Year * Age,
data=this.ds,
region=F,
labels=F,
lwd=2,
at=c(0, 0.01, 1),
panel=function(...){
panel.contourplot(...)
panel.segments(x0=c(1840, 1900, 2000, 1840),
x1=c(1900, 1900, 2000, 2000),
y0=c(40.5, 0, 0, 64),
y1=c(40.5, 40.5, 64, 64),
lty="dashed")
}
)
Plot.Final <- Part1+ Part2
print(Plot.Final)