[R] Alignment of the title in a key for xyplot in lattice.

Deepayan Sarkar deep@y@n@@@rk@r @end|ng |rom r-project@org
Tue Dec 24 08:08:49 CET 2019


On Tue, Dec 24, 2019 at 6:59 AM Jim Lemon <drjimlemon using 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 using 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 using 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.
>



More information about the R-help mailing list