0

A simple example of what I hope would work:

library(lattice)
xyplot(1~1, 
  key=list( 
    text=list( c("a", "b") ), 
    points=list(pch=21, fill=c("red", "blue")) ## note pch=21 => filled circle
  )
)

One would expect the points being used in the legend would be filled red, but this doesn't seem to be the case. As a parallel, this code works as expected:

xyplot(1~1, 
  key=list( 
    text=list( c("a", "b") ), 
    points=list(pch=21, col=c("red", "blue"))
  )
)

Any ideas how I can force lattice to use a specific fill for the legend points?

Kevin Ushey
  • 20,530
  • 5
  • 56
  • 88
  • 1
    I'm pretty sure I saw this exact question on either R-help or SO within the last month.http://stackoverflow.com/questions/15441661/symbol-fill-color-in-lattice-using-auto-key – IRTFM Mar 23 '13 at 00:36
  • 1
    A bug report and proposed patch were [filed here](http://r-forge.r-project.org/tracker/index.php?func=detail&aid=2587&group_id=638&atid=2567) with the package maintainers about 3 weeks ago. The basic problem is that the functions responsible for creating the key pass along many graphical parameters, but `fill` is not among them. A fix will be easy, when the package maintainers get around to it! – Josh O'Brien Mar 23 '13 at 02:17
  • 1
    This bug has been fixed in version 0.20-15. – Oscar Perpiñán Mar 26 '13 at 01:30

0 Answers0