[R] Leading in line-wrapped Lattice axis value and panel labels
p.murrell at auckland.ac.nz
Thu Sep 8 00:11:48 CEST 2005
Tim Churches wrote:
> Paul Murrell wrote:
>> Deepayan Sarkar wrote:
>> > On 9/7/05, Tim Churches <tchur at optushome.com.au> wrote:
>> >> Version 2.1.1 Platforms: all
>> >> What is the trellis parameter (or is there a trellis parameter) to
>> >> set the leading (the gap between lines) when long axis values
>> >> labels or panel header labels wrap over more than one line? By
>> >> default, there is a huge gap between lines, and much looking and
>> >> experimentation has not revealed to me a suitable parameter to
>> >> adjust this.
>> > There is none. Whatever grid.text does happens.
>> grid does have a "lineheight" graphical parameter. For example,
>> grid.text("line one\nlinetwo",
>> x=rep(1:3/4, each=3),
>> y=rep(1:3/4, 3),
>> Could you add this in relevant places in trellis.par Deepayan?
> Is there a work around we could use in the meantime, or should we
> attempt to hack trellis.par as per Paul's suggestion (gulp!)? I suppose
> that is like asking "Should we attempt to climb Teichelmann?" - it
> depends... We have increased the depth of the panel headers, but this
> wastes plotting area and the tops of the tees and effs on the upper line
> and the bottoms of the gees and whys on the bottom line are still cut
> off, so large is the gap between the two lines. And increasing the
> panel header depth it doesn't help with y-axis labels - typically the
> second line of one label will abut the first line of the next label,
> giving a results which is rather like:
> where the actual value labels are "Value One", "Value Two" etc and the
> "-" are the tick marks. Less than ideal.
> Suggestions for interim fixes (other than using abbreviated labels...
> we've thought of that) most welcome.
I don't think lattice explicitly sets lineheight so you could try
something like the following (push a [full-page] grid viewport that sets
lineheight then draw lattice plot within that) ...
states <- data.frame(state.x77,
state.name = dimnames(state.x77)[],
state.region = factor(state.region))
c("Northeast", "South", "North\n Central", "West")
xyp <- xyplot(Murder ~ Population | state.region, data = states,
groups = as.character(state.name),
panel = function(x, y, subscripts, groups)
ltext(x = x, y = y, label = groups[subscripts], srt = -50,
col = "blue",
cex=.9, fontfamily = "HersheySans"),
par.strip.text = list(cex = 1.3, font = 4, col = "brown",
lines = 2),
xlab = "Estimated Population\nJuly 1, 1975",
ylab = "Murder Rate \n(per 100,000 population)\n 1976",
main = "Murder Rates in US states")
# default line height for comparison
# control line height
... this does not work perfectly for me, but I'm not sure (yet) whether
that is a problem in grid, a problem in lattice, or a problem with
Hershey fonts (that are used in this example) so your mileage may vary.
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
64 9 3737599 x85392
paul at stat.auckland.ac.nz
More information about the R-help