Alignment of the title in a key for xyplot in lattice.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Alignment of the title in a key for xyplot in lattice.

Rolf Turner

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

______________________________________________
[hidden email] 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.

xmpl.pdf (13K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Alignment of the title in a key for xyplot in lattice.

Jim Lemon-4
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 <[hidden email]> 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
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Alignment of the title in a key for xyplot in lattice.

Rolf Turner

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

______________________________________________
[hidden email] 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.

xmpl2.pdf (13K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Alignment of the title in a key for xyplot in lattice.

Deepayan Sarkar-3
In reply to this post by Jim Lemon-4
On Tue, Dec 24, 2019 at 6:59 AM Jim Lemon <[hidden email]> 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 <[hidden email]> 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
> > ______________________________________________
> > [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Alignment of the title in a key for xyplot in lattice.

Eric Berger
In reply to this post by Rolf Turner
Lovely solution Rolf :-)

On Tue, Dec 24, 2019 at 8:42 AM Rolf Turner <[hidden email]> wrote:

>
> 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
> ______________________________________________
> [hidden email] 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.