Dear R-users I have some trouble to generate more than one key with xyplot using the legend argument. I would like one key with rectangles: library(lattice) library(grid) key1 <- list(rectangles = list(col= c(rev(heat.colors(5))[1:5], rev(heat.colors(5))[4:1])), title="Percentiles", space="right", text = list(lab = rev(c(" 5-15", "15-25", "25-35", "35-45", "45-55","55-65", "65-75", "75-85", "85-95"))), columns = 1) and another one with lines: key2 <- list(lines=list(col=2), text=list(lab="Mean")) Each of them works fine: xyplot(1~1, key = key1) xyplot(1~1, key = key2) Unfortunately I don't really understand which "fun" (for legend) I have to use. The following line does not work. xyplot(1~1, legend = list(right=list(key1, fun="grob"),top=list(key2, fun="grob"))) Kind Regards Markus ************LNSCNTMCS01*************************************************** The information in this E-Mail and in any attachments is CONFIDENTIAL and may be privileged. If you are NOT the intended recipient, please destroy this message and notify the sender immediately. You should NOT retain, copy or use this E-mail for any purpose, nor disclose all or any part of its contents to any other person or persons. Any views expressed in this message are those of the individual sender, EXCEPT where the sender specifically states them to be the views of Lloyd's. Lloyd's may monitor the content of E-mails sent and received via its network for viruses or unauthorised use and for other lawful business purposes." Lloyd's is authorised under the Financial Services and Markets Act 2000
On Thursday 24 February 2005 06:12, Gesmann, Markus wrote:> Dear R-users > > I have some trouble to generate more than one key with xyplot using > the legend argument. > I would like one key with rectangles: > > library(lattice) > library(grid) > key1 <- list(rectangles = list(col= c(rev(heat.colors(5))[1:5], > rev(heat.colors(5))[4:1])), > title="Percentiles", > space="right", > text = list(lab = rev(c(" 5-15", "15-25", > "25-35", "35-45", > "45-55","55-65", "65-75", "75-85", > "85-95"))), > columns = 1) > > and another one with lines: > > key2 <- list(lines=list(col=2), text=list(lab="Mean")) > > Each of them works fine: > > xyplot(1~1, key = key1) > xyplot(1~1, key = key2) > > Unfortunately I don't really understand which "fun" (for legend) I > have to use. > The following line does not work. > > xyplot(1~1, legend = list(right=list(key1, fun="grob"),top=list(key2, > fun="grob")))You want xyplot(1~1, legend = list(right = list(fun="draw.key", args = list(key = key1, draw = FALSE)), top = list(fun="draw.key", args = list(key = key2, draw = FALSE)))) ?draw.key should explain why. Deepayan