Rolf Turner
2019-Dec-23 22:26 UTC
[R] Alignment of the title in a key for xyplot in lattice.
The title of a key seems to be horizontally centred in the key; I would like to have it aligned with the left hand edge. I.e. I would like the first letter of the title to have the same horizontal position as the first letters of the text strings. E.g. in the attached example I would like the "P" in "Point type" to be directly above the "o" in "obsd" and "f" in "fitted". Is there any way to effect this? Thanks. cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 -------------- next part -------------- A non-text attachment was scrubbed... Name: xmpl.pdf Type: application/pdf Size: 10139 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20191224/8b4f5eb6/attachment.pdf>
Jim Lemon
2019-Dec-24 01:29 UTC
[R] Alignment of the title in a key for xyplot in lattice.
Hi Rolf, Following the docs back to draw.key, It looks like the ellipsis argument is ignored. I was hoping for a brilliant solution along the lines of: adj=0 that could be passed down the functions like a hot potato, but was disappointed. Jim On Tue, Dec 24, 2019 at 9:26 AM Rolf Turner <r.turner at auckland.ac.nz> wrote:> > > The title of a key seems to be horizontally centred in the key; I would > like to have it aligned with the left hand edge. I.e. I would like the > first letter of the title to have the same horizontal position as the > first letters of the text strings. > > E.g. in the attached example I would like the "P" in "Point type" to be > directly above the "o" in "obsd" and "f" in "fitted". > > Is there any way to effect this? Thanks. > > cheers, > > Rolf Turner > > -- > Honorary Research Fellow > Department of Statistics > University of Auckland > Phone: +64-9-373-7599 ext. 88276 > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
Rolf Turner
2019-Dec-24 06:41 UTC
[R] Alignment of the title in a key for xyplot in lattice.
On 24/12/19 2:29 pm, Jim Lemon wrote:> Hi Rolf, > Following the docs back to draw.key, It looks like the ellipsis > argument is ignored. I was hoping for a brilliant solution along the > lines of: > > adj=0 > > that could be passed down the functions like a hot potato, but was disappointed.Thanks for giving it some thought. Actually I've found a work-around: make the title the first entry of the text component of the key, with the corresponding entries of the other components being NA. And omitting the "title" argument. An example of the result is attached. It satisfies me, at least! :-) cheers, Rolf -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 -------------- next part -------------- A non-text attachment was scrubbed... Name: xmpl2.pdf Type: application/pdf Size: 10155 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20191224/2450278b/attachment.pdf>
Deepayan Sarkar
2019-Dec-24 07:08 UTC
[R] Alignment of the title in a key for xyplot in lattice.
On Tue, Dec 24, 2019 at 6:59 AM Jim Lemon <drjimlemon at gmail.com> wrote:> > Hi Rolf, > Following the docs back to draw.key, It looks like the ellipsis > argument is ignored. I was hoping for a brilliant solution along the > lines of: > > adj=0 > > that could be passed down the functions like a hot potato, but was disappointed.Yes, the implementation of title is quite rudimentary, and should be easy to enhance. The current invocation for drawing the title is essentially textGrob(label = key$title, gp = gpar(cex = key$cex.title, lineheight = key$lineheight)) which translates to (with defaults) textGrob(label = key$title, x = 0.5, y = 0.5, default.units = "npc", just = "centre", gp = gpar(cex = key$cex.title, lineheight = key$lineheight)) To control the justification, the user needs to be able to specify at least 'x' and 'just'. One should also be able to control other graphical parameters. A trickier issue is that the legend doesn't consider the title when computing its width. I have never been able to decide whether it should. Anyway, I have some long-pending pull requests for improving legend behaviour, which hopefully I will be able to get to soon. I will try to address this at the same time. -Deepayan> Jim > > On Tue, Dec 24, 2019 at 9:26 AM Rolf Turner <r.turner at auckland.ac.nz> wrote: > > > > > > The title of a key seems to be horizontally centred in the key; I would > > like to have it aligned with the left hand edge. I.e. I would like the > > first letter of the title to have the same horizontal position as the > > first letters of the text strings. > > > > E.g. in the attached example I would like the "P" in "Point type" to be > > directly above the "o" in "obsd" and "f" in "fitted". > > > > Is there any way to effect this? Thanks. > > > > cheers, > > > > Rolf Turner > > > > -- > > Honorary Research Fellow > > Department of Statistics > > University of Auckland > > Phone: +64-9-373-7599 ext. 88276 > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. >