[R] lattice contourplot background covers inward-facing ticks
Richard.Cotton at hsl.gov.uk
Richard.Cotton at hsl.gov.uk
Mon Nov 24 18:14:40 CET 2008
> 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
The easiest way is to make the contours semi-transparent by adding
alpha.regions=0.7 (or whatever number you prefer) to the call to
contourplot. This has a couple of poosible disadvantages though:
1. It will change the colours you used
2. You can't print to some devices (windows metafile isn't supported)
Other solutions involve a lot of messing about. You could manually draw
ticks using grid.xaxis (and grid.yaxis) in the grid package, or stop
plotting to the edges of the panel.
Regards,
Richie.
Mathematical Sciences Unit
HSL
------------------------------------------------------------------------
ATTENTION:
This message contains privileged and confidential inform...{{dropped:20}}
More information about the R-help
mailing list