[R] panel function in a conditioned lattice graphic
Deepayan Sarkar
deepayan at stat.wisc.edu
Sun May 30 09:14:02 CEST 2004
On Saturday 29 May 2004 20:18, Anthony Darrouzet-Nardi wrote:
> I have a followup question. Suppose I want to encode two different
> variables within a panel: one variable encoded by plotting character
> and one variable encoded by symbol color (as if I could use two
> "groups" variables). The dataframe I discussed above also includes a
> variable called treatment. If I start with the existing code modified
> with your suggestions:
>
> xyplot(coversage ~ dryout | year,
> data = dryoutcover,
> groups = block,
> panel = function(x,y, ...) {
> panel.lmline(x,y)
> panel.superpose(x,y,
> pch = 49:54,
> cex = rep(2,6),
> col = rep("black", 6), ...)
> }
> )
>
> how could I make all of the symbols of one treatment red and all of
> the symbols of the other black while maintaining the encodings of
> block by plotting character? This would be a superbly useful
> technique as it would allow 4 dimensional data on a single panel
> (maybe even 5 using a point cloud!).
I would use the same construct, forming a new grouping variable and
using suitably modified pch and col arguments:
xyplot(coversage ~ dryout | year, data=dryoutcover, cex = 2,
groups = interaction(block, treatment),
pch = rep(49:54, 2),
col = rep(c('red', 'black'), each = 5))
(2 and 5 being the nlevels() of treatment and block respectively). You
would also probably prefer factor(year) rather than year.
Deepayan
More information about the R-help
mailing list