Search the entire project
This project's trackers
This project's forums
[#2587] Bordered legend icons and Text in plots
James Hawley (
Deepayan Sarkar (deepayan)
Bordered legend icons and Text in plots
My colleagues and I use lattice for a variety of different purposes, and we came across a couple issues involving legend.R and update.trellis.R.
1. When using xyplot, the shapes in the plots are able to have borders and fill colours, but not so in the legend. I created a short script to isolate the problem (see legend-icons.R and Nofill.png).
After some tracing through the source code, it turned out that the "fill" argument in "key" was being dropped by the line
pars <- pars[!sapply(pars, is.null)] # remove NULL components (lines 302 and 322)
As in key$fill was NULL when passed. The issue seems to be from the function process.key(). The output list does not return "fill" as one of its arguments, and was dropped whenever "key" was processed.
2. Giving multiple grobs to the 'inside' part of 'legend' only uses the first grob if you use update.trellis to provide them. This is caused by the way modifyList handles list elements with the same name (which is called by update.trellis), and can be worked around (see update.trellis.R).
The issue without modification to your code can be seen in Notext.png (created by legend-text.R). Multiple grobs could still be given to 'inside' via the other methods (e.g. xyplot and the like).
I've made a few modifications to the source code and uploaded them here as well (legend.R and update.trellis.R).
For Issue 1, I added the line "fill = fill," to the output list of process.key(), and this seems to have fixed the issue (see legend.R line 216 and Fill.png for results).
For Issue 2 there is a workaround in update.trellis.R lines 267-275 (see Text.png for the results).
Date: 2013-07-19 08:11
Both issues now fixed in SVN