[R] textbox in lattice

baptiste auguie baptiste.auguie at googlemail.com
Tue Jun 1 21:21:59 CEST 2010


On 1 June 2010 21:12, Noah Silverman <noah at smartmediacorp.com> wrote:
> That's amazing.  (It would have taken me many hours to figure this out
> on my own.)
>
> Two quick last questions and then I'm off to plotting:
> 1) How can I reduce the font size of the table. (It is huge on my plot.)

try this,

grid.table(head(iris), gp=gpar(cex = 0.5), padding.h = unit(1, "mm"),
padding.v = unit(1, "mm"))

You can also fine tune individually the header vs. core text elements.
Try reading ?tableGrob and ?gpar
> 2) How can I control the ratio of "plot area" to "table area" in the grid?

If you decide to use arrange() rather than lower-level Grid functions,
you can use the heights argument. "null" units give you control over
the relative size of the two objects on the page,

unit(c(3,1),"null")

means that the first object (plot) will take up 3 times more space in
the vertical direction than the table. For more control, see
?grid.layout ?viewport etc.

baptiste

>
> Thanks a million!
>
> -N
>
>
> On 6/1/10 12:07 PM, baptiste auguie wrote:
>> Please do read the posting guide, in particular regarding reproducible examples.
>>
>> You can use a Grid layout to place the lattice plot and a table in the
>> same page. For example,
>>
>> library(lattice)
>>  library(coda)
>>  library(gridExtra)
>>    x <- matrix(runif(2200),ncol=22)
>>    m <- as.mcmc(x)
>>   p = xyplot(m, layout = c(2, 11))
>>
>>  pdf(,height=15)
>>  arrange(p, tableGrob(as.matrix(summary(iris)), theme=theme.white()),
>> heights= unit(c(3,1),"null"))
>>  dev.off()
>>
>> HTH,
>>
>> baptiste
>> On 1 June 2010 20:52, Noah Silverman <noah at smartmediacorp.com> wrote:
>>
>>> Hi,
>>>
>>> It is a matrix.  Exactly the output of summary(foo)
>>>
>>> Would you call the gridExtra command before the xyplot command or after?
>>>
>>> Now I have:
>>>
>>> temp <- as.mcmc(foo)
>>> xyplot(temp, layout=c(2,11), main="plot title")
>>>
>>>
>>> THANKS!!
>>>
>>>
>>> On 6/1/10 11:35 AM, baptiste auguie wrote:
>>>
>>>> Hi,
>>>>
>>>> It's not clear what you mean by summary text without a minimal
>>>> reproducible example. If your text is ordered as a matrix or a
>>>> data.frame, you might want to try this grid function,
>>>>
>>>> gridExtra::grid.table(as.matrix(summary(iris)), theme=theme.white())
>>>>
>>>> If your text has the form of a paragraph, the RGraphics::splitTextGrob
>>>> function might help.
>>>>
>>>> HTH,
>>>>
>>>> baptiste
>>>>
>>>>
>>>>
>>>> On 1 June 2010 19:37, Noah Silverman <noah at smartmediacorp.com> wrote:
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> I want to add a box at the bottom of a lattice window (device/page?).
>>>>>
>>>>> Lattice has drawn a nice group of panels with all the plots I need.  How
>>>>> do I add my own summary text at the bottom (several lines worth?)
>>>>>
>>>>> ______________________________________________
>>>>> R-help at r-project.org 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.
>>>>>
>>>>>
>>>>>
>



More information about the R-help mailing list