# [R] Lattice plot questions

Paul, David A paulda at BATTELLE.ORG
Fri Aug 29 18:14:42 CEST 2003

```Win2k, R1.7.1:

I am currently working with some growth curve data from a
biotoxicology experiment.  Each of 12 subjects had their blood
drawn at 0, 2, 4, 6, 8, and 10 weeks.  For the purposes of the
project, it would be helpful if I were able to do the following:

a.  Produce 12 panels, each displaying the *same* data, with
the "strip" at the top of a particular panel showing
exactly one of the subject id's
b.  For a particular panel, plot the time course data for
the subject whose id appears in the strip in some
really obvious color (like yellow, red, or blue),
with circles at each time point, and connecting the
"dots".  In the same panel, those subjects whose id's
did NOT appear in the strip would ideally have their
data plotted in black, possibly with no symbols at
any of the time points, but still connecting the
"dots".

I apologize if the description of what is needed is vague.
It is possible to address (a) by duplicating the data set
twelve times and cbind()ing a factor variable so that each
of the duplicated data sets is associated with exactly one
of the subject id's.  I have done this, and the code

subjects <- foo\$subject.id
superpose.symbol <- trellis.par.get("superpose.symbol")
xyplot(log.response ~ week | factor.variable, data = foo,
panel = panel.superpose,
groups = subjects,
key = list(space = "top", columns = 6, transparent = TRUE,
text = list(levels(subjects)),
points = Rows(superpose.symbol,1:7))
)

works, with "factor.variable" corresponding to the cbind()ed
factor variable.  Unfortunately, I have been unable to figure
out how to do (b).  I would also like to determine a more
memory efficient way of doing (a) -- even though my current
data set is small (only 10 weeks of data per subject), that will
change.

Also, an examination of "superpose.symbol" reveals the
following:

> superpose.symbol <- trellis.par.get("superpose.symbol")
> superpose.symbol
\$cex
[1] 0.8 0.8 0.8 0.8 0.8 0.8 0.8

\$col
[1] "#00ffff" "#ff00ff" "#00ff00" "#ff7f00" "#007eff" "#ffff00" "#ff0000"

\$font
[1] 1 1 1 1 1 1 1

\$pch
[1] "o" "o" "o" "o" "o" "o" "o"

This seems to indicate that lattice graphics are restricted to
no more than seven colors, though I cannot believe that this is true.
lattice plots and how to denote them?  (I find "#ff7f00" to be
a little cryptic, for example.)  Is there a table that relates
these ?hexadecimal? numbers to descriptions like "navy blue"
for Win2k?

Finally, is it possible to cause superpose.symbol to default to
more than 7 \$cex/\$col/\$font/\$pch values?  Since I am working with
12 subjects, plots that assign a different color to each wind up
duplicating colors and symbols at some point.