Re: [R] panel function in a conditioned lattice graphic

About this list Date view Thread view Subject view Author view Attachment view

From: Anthony Darrouzet-Nardi (anthony@darrouzet-nardi.net)
Date: Mon 31 May 2004 - 10:55:53 EST


Message-id: <p0521061ebce02f09a3d9@[4.243.164.183]>


>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

Bravo! That works wonderfully. I foresee myself using this method a
lot. For the record, nlevels(block) is 6, so each = 6 in the col
argument for the final version. Makes sense to switch to factor(year)
as well (like the barley data).

Thanks for your help,

Anthony

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:14 EST