[R] update'ing trellis object

Deepayan Sarkar deepayan.sarkar at gmail.com
Sun Oct 4 21:45:55 CEST 2009


On Sat, Oct 3, 2009 at 7:35 PM, David Winsemius <dwinsemius at comcast.net> wrote:
>
> On Oct 3, 2009, at 7:05 PM, Sebastian P. Luque wrote:
>
>> Hi,
>>
>> I thought the following would only remove the legend element of a
>> trellis object, but it actually removes both the legend and key
>> elements:
>>
>> ---<--------------------cut
>> here---------------start------------------->---
>> fig <- xyplot(Sepal.Length ~ Petal.Length, groups=Species, data=iris,
>>             key=list(x=1, y=0.02, corner=c(1, 0), size=3, between=1,
>>               text=list(levels(iris$Species))),
>>             legend=list(inside=list(fun="draw.key", x=0, y=1,
>>                           corner=c(0, 1),
>>                           args=list(key=list(text=list("a)", cex=1.5)),
>>                             draw=FALSE))))
>> update(fig, legend=NULL)
>> ---<--------------------cut
>> here---------------end--------------------->---
>>
>> Is this the right way to remove an element from the object, using
>> update.trellis()?  Thanks.
>>
> It probably depends on the element. In the case of "key", it is a descendant
> of the legend list so when you make legend NULL you are wiping out all of
> its descendants as well:

Yes, unfortunately the trellis object cannot distinguish between the
"legend" and the "key" any more.

-Deepayan




More information about the R-help mailing list