Hi,
>> Using the gtable_filter I was able to extract the panel and legend. Now to create sufficient amount of room for the legend I would have to know its size. Ideally I would like to calculate it using grobWidth and grobHeight, however this gives me an error. Then I noticed the widths and heights slots in gtable. The widths seem to be adequate, but height is something like 0.5cm for a rather large legend. What would be the correct way to calculate the height of the legend? Have I missed some functions in gtable that would do it for me?
>
> Oh hmmm, that's probably because the height isn't calculated correctly
> for the legend. Winston, can you please look into as part of the
> gtable stuff?
The legend, place left (or right) side of the panel, has height of
1null. This means the height of the grob (this is gTree) is determined
by main panel.
In the case of top/bottom legend, the width is 1null.
You may get the height by accessing the height element of the gTree:
d> p <- qplot(1:3, 1:3, colour = 1:3, size = 1:3)
d> r <- gtable_filter(ggplot_gtable(ggplot_build(p)), "guide-box")
d> gg <- r$grobs[[1]]
d> gg$height
[1] sum(0.5lines, sum(1.5mm, 2.42424488799749mm, 2.032mm, 40.64mm,
1.5mm), 0.5lines, sum(1.5mm, 2.42424488799749mm, 2.032mm, 8.128mm,
8.128mm, 8.128mm, 8.128mm, 8.128mm, 1.5mm), 0.5lines)
kohske
2012/6/26 Hadley Wickham <
had...@rice.edu>:
Kohske Takahashi <
takahash...@gmail.com>
Assistant Professor,
Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html