Subject: xyplot: legend title + legend on 1 line

From: RMan54 <[email-masked]>
Date: Fri, 15 Dec 2006 12:41:06 -0800 (PST)

Does anybody know how in xyplot to put the legend title on one line with the
legend? I can get the legend on one line with columns=... but the title is
always on top. I tried a custom key with key=... and text=... but I can't
put the title text in front of the plotting symbol.

I am looking for the following layout of the legend, on one line:

"Legend Title:" + plot symbol1 + legend text1 + plot symbol2 + legend text2
+ ...

Thanks. Rene
 
-- 
View this message in context: http://www.nabble.com/xyplot%3A-legend-title-%2B-legend-on-1-line-tf2829327.html#a7898800
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
[email-masked] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

---

From: "Deepayan Sarkar" <[email-masked]>
Date: Fri, 15 Dec 2006 13:01:56 -0800

> "Legend Title:" + plot symbol1 + legend text1 + plot symbol2 + legend text2

You can create a grob (grid object) representing this legend, or a
function that produces such a grob, and pass it to xyplot through the
'legend' argument (see ?xyplot). The 'key' argument essentially
controls one such built-in function, namely 'draw.key', which does not
support such legends.

Note however, that column types can be repeated in key, so you might
be able to fake such a legend. E.g.:

xyplot(1 ~ 1,
       key =
       list(text = list("title: ", font = 2),
            points = list(pch = 1),
            text = list("1"),
            points = list(pch = 2),
            text = list("2")))

-Deepayan