Here is the code for my recent query:
The first part just sets up the data. It's the last part 
titled "individual depth graph" where the actual graphics code comes in

Thx
--Seth



library(lattice)
setwd("c:/sethdocs/3 Light and PLAS txs/8 Figures/Fg 6 Soil wetness")

d <- read.table("2007 data.txt", header=TRUE, sep = ",")
str(d)
CC <- rep(6:96,3)
depth <- rep(1:3, each=91)
g <- data.frame(depth, CC)


### 0 - 15 PRE parms ####

model <- function(a, b, f, CC){
        t <- a + exp(f-(b*CC))
        return(t)
        }

a = 0.08
b = 0.275
f = -1.18

g$t <- ifelse(g$depth==1,round(model(a, b, f, g$CC),3),g$t==NA)

# g$depth = rep("0-15",nrow(g))

### 15 - 40 PRE parms ######

a  <- 0.14
b  <- 0.0683
f  <- -1.9

g$t  <- ifelse(g$depth==2, round(model(a, b, f, g$CC),3),g$t)

####### 40 - 70 PRE parms, graphs ##############

a <- 0.291
b <- -0.00094
}
a <- 0.25
g$t <- ifelse(g$depth==3, a, g$t)

s <- split(g, depth)

######## Individual depth graph ###############################

sup.sym <- Rows(trellis.par.get("superpose.symbol"),1:4)
sup.sym
sup.sym$pch[1:4] <- c(6,2,0,1)

# show.settings()

mypanel <- function(..., alt.data){
        panel.xyplot(...)
        with(alt.data[[which.packet()[1]]],             # 'with' evaluates 
statement and includes with version of dataset in local workspace
      panel.xyplot(x = CC, y = t, type="l", col="black"))
        }

graf <- xyplot(t~CC|dep,d, groups=tx, alt.data=s, 
        pch = sup.sym$pch, 
        cex=1.5,                                                # symbol 
size
        layout = c(3,1),
        xlab = list("Canopy cover (%)", cex=1.7),
        ylab = list(expression(paste("soil moisture 
(m"^{"3"},"/m"^{"3"},")")), 
                cex=1.2),
        scales=list(x = list(cex=1.3), y = list(cex=1.3)),
        strip = strip.custom(bg="transparent"),
        panel = mypanel,
        key = list(
                text = c("heavy thin","light thin", "control"," group"), 
                columns=2,
                points=list(pch=sup.sym)
        ),
        aspect="xy")
graf



Dr. Seth  W. Bigelow
Biologist, USDA-FS Pacific Southwest Research Station
1731 Research Park Drive, Davis California




Felix Andrews <fe...@nfrac.org> 
Sent by: foolish.andr...@gmail.com
06/22/2010 04:29 PM

To
Seth W Bigelow <sbige...@fs.fed.us>
cc

Subject
Re: [R] Lattice legend






Plase post your code (to the list). We can't help if we don't know
what you are doing.

Cheers
-Felix

On 23 June 2010 08:54, Seth W Bigelow <sbige...@fs.fed.us> wrote:
> I have a moderately complex graph with three panels. There are data 
points
> plotted, and fitted lines are added using a panel function, which 
includes
>
> "with(alt.data[[which.packet()[1]]]" statements. It all graphs out
> beautifully, but none of the usual tricks to get the proper legend to 
plot
> are working, i.e., using auto.key, key, etc.
> One message I keep getting is
>
> Error in key[[i]][[1]] <- NULL :  more elements supplied than there are 
to
> replace
>
>
>
> Any suggestions will be appreciated
>
> --Seth
>
>
> Dr. Seth  W. Bigelow
> Biologist, USDA-FS Pacific Southwest Research Station
> 1731 Research Park Drive, Davis California
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



-- 
Felix Andrews / 安福立
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andr...@anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/

"year","survey","tx","bk","dayt","t","CC","doy","dep"
2007,1,"Control","Tamarack",2007-07-26,0.0635555565555556,72,207,"0-15"
2007,2,"Control","Tamarack",2007-08-30,0.0340000001111111,72,242,"0-15"
2007,3,"Control","Tamarack",2007-09-26,0.105444443555556,72,269,"0-15"
2007,1,"50% target","Tamarack",2007-07-26,0.111555553222222,57,207,"0-15"
2007,2,"50% target","Tamarack",2007-08-30,0.0716666654444444,57,242,"0-15"
2007,3,"50% target","Tamarack",2007-09-26,0.115444445333333,57,269,"0-15"
2007,1,"30% target","Tamarack",2007-07-26,0.0654444455555555,40.25,207,"0-15"
2007,2,"30% target","Tamarack",2007-08-30,0.0356666667777778,40.25,242,"0-15"
2007,3,"30% target","Tamarack",2007-09-26,0.0728888888888889,40.25,269,"0-15"
2007,1,"Group","Tamarack",2007-07-26,0.147444444444444,6.11,207,"0-15"
2007,2,"Group","Tamarack",2007-08-30,0.103444444,6.11,242,"0-15"
2007,3,"Group","Tamarack",2007-09-26,0.161222222666667,6.11,269,"0-15"
2007,1,"Control","Deanes",2007-07-24,0.0986666674444445,79,205,"0-15"
2007,2,"Control","Deanes",2007-08-28,0.080222222,79,240,"0-15"
2007,3,"Control","Deanes",2007-09-24,0.111777779222222,79,267,"0-15"
2007,1,"50% target","Deanes",2007-07-24,0.117111111,51.5,205,"0-15"
2007,2,"50% target","Deanes",2007-08-28,0.0806666671111111,51.5,240,"0-15"
2007,3,"50% target","Deanes",2007-09-24,0.141888886666667,51.5,267,"0-15"
2007,1,"30% target","Deanes",2007-07-24,0.0708888898888889,52.75,205,"0-15"
2007,2,"30% target","Deanes",2007-08-28,0.0484444445555556,52.75,240,"0-15"
2007,3,"30% target","Deanes",2007-09-24,0.0682222224444444,52.75,267,"0-15"
2007,1,"Group","Deanes",2007-07-24,0.121555555666667,12.46,205,"0-15"
2007,2,"Group","Deanes",2007-08-28,0.0794444453333333,12.46,240,"0-15"
2007,3,"Group","Deanes",2007-09-24,0.131111111111111,12.46,267,"0-15"
2007,1,"Control","Pineleaf",2007-07-25,0.0836666672222222,79.5,206,"0-15"
2007,2,"Control","Pineleaf",2007-08-29,0.0733333343333333,79.5,241,"0-15"
2007,1,"50% target","Pineleaf",2007-07-25,0.0916666671111111,62.63,206,"0-15"
2007,2,"50% target","Pineleaf",2007-08-29,0.0664444445555556,62.63,241,"0-15"
2007,3,"50% target","Pineleaf",2007-09-25,0.0761111107777778,62.63,268,"0-15"
2007,1,"30% target","Pineleaf",2007-07-25,0.106888888888889,54.25,206,"0-15"
2007,2,"30% target","Pineleaf",2007-08-29,0.0865555551111111,54.25,241,"0-15"
2007,1,"Group","Pineleaf",2007-07-25,0.0634444446666667,18.84,206,"0-15"
2007,2,"Group","Pineleaf",2007-08-29,0.0431111108888889,18.84,241,"0-15"
2007,3,"Group","Pineleaf",2007-09-25,0.0751111108888889,18.84,268,"0-15"
2007,1,"Control","Tamarack",2007-07-26,0.0967777777777778,72,207,"15-40"
2007,2,"Control","Tamarack",2007-08-30,0.0902222222222222,72,242,"15-40"
2007,3,"Control","Tamarack",2007-09-26,0.107,72,269,"15-40"
2007,1,"50% target","Tamarack",2007-07-26,0.141,57,207,"15-40"
2007,2,"50% target","Tamarack",2007-08-30,0.118888888888889,57,242,"15-40"
2007,3,"50% target","Tamarack",2007-09-26,0.112777777777778,57,269,"15-40"
2007,1,"30% target","Tamarack",2007-07-26,0.105111111111111,40.25,207,"15-40"
2007,2,"30% target","Tamarack",2007-08-30,0.0866666666666667,40.25,242,"15-40"
2007,3,"30% target","Tamarack",2007-09-26,0.0977777777777778,40.25,269,"15-40"
2007,1,"Group","Tamarack",2007-07-26,0.238,6.11,207,"15-40"
2007,2,"Group","Tamarack",2007-08-30,0.218777777777778,6.11,242,"15-40"
2007,3,"Group","Tamarack",2007-09-26,0.225888888888889,6.11,269,"15-40"
2007,1,"Control","Deanes",2007-07-24,0.185333333333333,79,205,"15-40"
2007,2,"Control","Deanes",2007-08-28,0.178333333333333,79,240,"15-40"
2007,3,"Control","Deanes",2007-09-24,0.193555555555556,79,267,"15-40"
2007,1,"50% target","Deanes",2007-07-24,0.161222222222222,51.5,205,"15-40"
2007,2,"50% target","Deanes",2007-08-28,0.135666666666667,51.5,240,"15-40"
2007,3,"50% target","Deanes",2007-09-24,0.127,51.5,267,"15-40"
2007,1,"30% target","Deanes",2007-07-24,0.207222222222222,52.75,205,"15-40"
2007,2,"30% target","Deanes",2007-08-28,0.1745,52.75,240,"15-40"
2007,3,"30% target","Deanes",2007-09-24,0.192666666666667,52.75,267,"15-40"
2007,1,"Group","Deanes",2007-07-24,0.253111111111111,12.46,205,"15-40"
2007,2,"Group","Deanes",2007-08-28,0.256888888888889,12.46,240,"15-40"
2007,3,"Group","Deanes",2007-09-24,0.256666666666667,12.46,267,"15-40"
2007,1,"Control","Pineleaf",2007-07-25,0.156333333333333,79.5,206,"15-40"
2007,2,"Control","Pineleaf",2007-08-29,0.125125,79.5,241,"15-40"
2007,1,"50% target","Pineleaf",2007-07-25,0.1175,62.63,206,"15-40"
2007,2,"50% target","Pineleaf",2007-08-29,0.11525,62.63,241,"15-40"
2007,3,"50% target","Pineleaf",2007-09-25,0.127375,62.63,268,"15-40"
2007,1,"30% target","Pineleaf",2007-07-25,0.235444444444444,54.25,206,"15-40"
2007,2,"30% target","Pineleaf",2007-08-29,0.19775,54.25,241,"15-40"
2007,1,"Group","Pineleaf",2007-07-25,0.164666666666667,18.84,206,"15-40"
2007,2,"Group","Pineleaf",2007-08-29,0.153333333333333,18.84,241,"15-40"
2007,3,"Group","Pineleaf",2007-09-25,0.158777777777778,18.84,268,"15-40"
2007,1,"Control","Tamarack",2007-07-26,0.158777777777778,72,207,"40-70"
2007,2,"Control","Tamarack",2007-08-30,0.144444444444444,72,242,"40-70"
2007,3,"Control","Tamarack",2007-09-26,0.145111111111111,72,269,"40-70"
2007,1,"50% target","Tamarack",2007-07-26,0.219875,57,207,"40-70"
2007,2,"50% target","Tamarack",2007-08-30,0.197125,57,242,"40-70"
2007,3,"50% target","Tamarack",2007-09-26,0.22925,57,269,"40-70"
2007,1,"30% target","Tamarack",2007-07-26,0.145444444444444,40.25,207,"40-70"
2007,2,"30% target","Tamarack",2007-08-30,0.121666666666667,40.25,242,"40-70"
2007,3,"30% target","Tamarack",2007-09-26,0.121333333333333,40.25,269,"40-70"
2007,1,"Group","Tamarack",2007-07-26,0.273666666666667,6.11,207,"40-70"
2007,2,"Group","Tamarack",2007-08-30,0.268625,6.11,242,"40-70"
2007,3,"Group","Tamarack",2007-09-26,0.257888888888889,6.11,269,"40-70"
2007,1,"Control","Deanes",2007-07-24,0.295222222222222,79,205,"40-70"
2007,2,"Control","Deanes",2007-08-28,0.300666666666667,79,240,"40-70"
2007,3,"Control","Deanes",2007-09-24,0.307625,79,267,"40-70"
2007,1,"50% target","Deanes",2007-07-24,0.196375,51.5,205,"40-70"
2007,2,"50% target","Deanes",2007-08-28,0.17,51.5,240,"40-70"
2007,3,"50% target","Deanes",2007-09-24,0.156125,51.5,267,"40-70"
2007,1,"30% target","Deanes",2007-07-24,0.242666666666667,52.75,205,"40-70"
2007,2,"30% target","Deanes",2007-08-28,0.198166666666667,52.75,240,"40-70"
2007,3,"30% target","Deanes",2007-09-24,0.231888888888889,52.75,267,"40-70"
2007,1,"Group","Deanes",2007-07-24,0.395666666666667,12.46,205,"40-70"
2007,2,"Group","Deanes",2007-08-28,0.401888888888889,12.46,240,"40-70"
2007,3,"Group","Deanes",2007-09-24,0.379888888888889,12.46,267,"40-70"
2007,1,"Control","Pineleaf",2007-07-25,0.341777777777778,79.5,206,"40-70"
2007,2,"Control","Pineleaf",2007-08-29,0.2152,79.5,241,"40-70"
2007,1,"50% target","Pineleaf",2007-07-25,0.2195,62.63,206,"40-70"
2007,2,"50% target","Pineleaf",2007-08-29,0.22125,62.63,241,"40-70"
2007,3,"50% target","Pineleaf",2007-09-25,0.21325,62.63,268,"40-70"
2007,1,"30% target","Pineleaf",2007-07-25,0.371333333333333,54.25,206,"40-70"
2007,2,"30% target","Pineleaf",2007-08-29,0.434666666666667,54.25,241,"40-70"
2007,1,"Group","Pineleaf",2007-07-25,0.286333333333333,18.84,206,"40-70"
2007,2,"Group","Pineleaf",2007-08-29,0.273,18.84,241,"40-70"
2007,3,"Group","Pineleaf",2007-09-25,0.270666666666667,18.84,268,"40-70"
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to