[R] Lattice xyplot(): adding a legend

Rich Shepard rshepard at appl-ecosys.com
Wed Oct 19 21:48:01 CEST 2016

On Wed, 19 Oct 2016, David Winsemius wrote:

> The `legend` function is used with base graphics plotting (as is the par
> function).


   And that's how I used it before so it is the wrong template for this plot.
Mea culpa!

> I think you might first read ?Lattice since it makes reference to the fact
> that you can update trellis structures after they have been created.

   That's what I was trying to do but with the incorrect name.

> The commands to add "legend" features to lattice plots are found under the
> argument items with names "key". Search in ?xyplot for the strings
> 'legend' and 'key'. It would probably be easier to incorporate these in a
> new plot call. There are several examples (well, four anyway) at the
> ?xyplot page. Since you mentioned having Sarkar's book, the place to look
> for more examples is chapter 9 "Labels and Legends".

   I did read that but mis-applied what I read. Tried auto.key but that did
not work as desired. Now I know to learn how to apply 'key'.



More information about the R-help mailing list