Skip to content

lattice legen and auto.key conflict

4 messages · GOUACHE David, Bert Gunter, Deepayan Sarkar +1 more

#
David:

I think one needs to carefully parse the xyplot help, where it says:

"To use more than one legend, or to have arbitrary legends not
constrained by the structure imposed by key, use the legend argument.
"

So I presume that this is to be interpreted as: "ONLY the legend
argument will be used when both key(including auto.key) and legend
arguments are given." However, this is not clear to me either. The
Help appears to leave the behavior when one tries to use both
unspecified.

-- Bert

On Mon, Jul 30, 2012 at 9:10 AM, GOUACHE David
<D.GOUACHE at arvalisinstitutduvegetal.fr> wrote:

  
    
#
On Mon, Jul 30, 2012 at 10:16 PM, Bert Gunter <gunter.berton at gene.com> wrote:
The help could indeed use some love.

Note however, that the entry for 'auto.key' (surely relevant here) says that:

          More precisely, if 'auto.key' is not 'FALSE', 'groups' is
          non-null, and there is no 'key' or 'legend' argument
          specified in the call, a key is created with 'simpleKey' with
          'levels(groups)' as the first ('text') argument.

And that condition is not satisfied here.

So that leaves the following two options (use key=, or update). The
documentation is silent about whether or not these should be
successful, but fortunately both seem to work.

xyplot(Sepal.Length+Sepal.Width~Petal.Length+Petal.Width, data=iris,
       groups = Species,
       key = simpleKey(text = levels(iris$Species), space="right"),
       legend=list(bottom=list(fun=grid.text,args=list(label="youpi !"))))

## or

p <- xyplot(Sepal.Length+Sepal.Width~Petal.Length+Petal.Width,
            data=iris, groups=Species, auto.key=list(space="right"))

update(p, legend=list(bottom=list(fun=grid.text,args=list(label="youpi !"))))

(I wish that reading lattice help would be less like trying to follow
an Asimov robot story, but there are too many possible interactions to
document both comprehensively and accurately.)

-Deepayan
#
On 2012-07-30 23:55, Deepayan Sarkar wrote:

            
I, Robot, having assessed said lattice help, determine it to be
admirable in execution. My master agrees.

Peter Ehlers