# [R] lattice contourplot background covers inward-facing ticks

baptiste auguie ba208 at exeter.ac.uk
Mon Nov 24 19:49:13 CET 2008

```I believe you can simply modify the panel function to replot the axes
on top with panel.axis(),

library(lattice)

model <- function(a,b,c,d,e, f, X1,X2)          # provide model function
# for contour plot
{J <- a + (b*X1) + (c*X2) + (d*X1*X2) + e*(X1^2) + f*(X2^2)
pp <- exp(J)/(1+exp(J))
return(pp)}

g <- expand.grid(X1= seq(0.3,0.9,0.01), X2 = seq(0.3,1, 0.01))
g\$z <- model(-29, -14, 52, 80, -3, -56, g\$X1, g\$X2)             # Create
# variable z using gridded data, model, and variables

contourplot(z ~ X1 * X2,panel=function(...){panel.levelplot(...);
panel.axis("bottom",  half = FALSE,labels=F)
panel.axis("left",  half = FALSE,labels=F)
},
data = g,
region = TRUE,         # Adds color to background
cuts = 10,                     # Number of contour intervals...(and
color
# intervals!)
scales = list(tck = c(-1,-1))  # ticks go inward
)   ### END

Hope this helps,

baptiste

On 24 Nov 2008, at 16:35, Seth W Bigelow wrote:

> I wish to have inward-pointing ticks on my contourplot graph, but the
> colored background produced by the "region=TRUE" statement covers the
> ticks up, is there any way around this? Sample code below.  --Seth
>
> library(lattice)
>
> model <- function(a,b,c,d,e, f, X1,X2)          # provide model
> function
> for contour plot
> {J <- a + (b*X1) + (c*X2) + (d*X1*X2) + e*(X1^2) + f*(X2^2)
>  pp <- exp(J)/(1+exp(J))
>  return(pp)}
>
> g <- expand.grid(X1= seq(0.3,0.9,0.001), X2 = seq(0.3,1, 0.001))
> g\$z <- model(-29, -14, 52, 80, -3, -56, g\$X1, g\$X2)             #
> Create
> variable z using gridded data, model, and variables
>
> contourplot(z ~ X1 * X2,
> data = g,
> region = TRUE,         # Adds color to background
> cuts = 10,                     # Number of contour intervals...(and
> color
> intervals!)
> scales = list(tck = c(-1,-1))  # ticks go inward
> )   ### END
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> and provide commented, minimal, self-contained, reproducible code.

_____________________________

Baptiste Auguié

School of Physics
University of Exeter