Skip to content

Conversation

@pmur002
Copy link
Contributor

@pmur002 pmur002 commented Jul 26, 2015

No description provided.

@hadley
Copy link
Member

hadley commented Feb 2, 2016

Can you remind me exactly what this did?

@pmur002
Copy link
Contributor Author

pmur002 commented Feb 2, 2016

This changes the way that "gtable" objects (and "gtableChild" objects)
get drawn.

The official 'gtable' package uses grid.draw() methods, which creates
problems if you want to fiddle with the grobs post-drawing (e.g., with
grid.edit()), which also creates problems for packages that want to
fiddle with the grobs post-drawing (e.g., 'gridSVG').

The fork changes to using makeContent() and makeContext() methods. This
makes it possible to fiddle with grobs post-drawing, with the caveat
that you have to call grid.force().

Here's a simple example, with the official 'gtable' - the important bit
is the output of grid.ls(), which shows that we cannot see all of the
grobs representing the legend that was drawn (we can only see the parent
object, 'guide-box.3-5-3-5') ...

library(ggplot2)
qplot(mpg, wt, data=mtcars, colour=cyl)
library(grid)
grid.ls()
GRID.gTableParent.48
background.1-6-6-1
spacer.4-3-4-3
panel.3-4-3-4
grill.gTree.15
panel.background..rect.6
panel.grid.minor.y..polyline.8
panel.grid.minor.x..polyline.10
panel.grid.major.y..polyline.12
panel.grid.major.x..polyline.14
geom_point.points.2
panel.border..zeroGrob.3
axis-l.3-3-3-3
axis.line.y..zeroGrob.27
axis
axis-b.4-4-4-4
axis.line.x..zeroGrob.20
axis
xlab.5-4-5-4
GRID.text.31
ylab.3-2-3-2
GRID.text.34
guide-box.3-5-3-5
title.2-4-2-4

Here's the same example using the 'gtable' fork - again, the important
bit is the grid.ls() output, which just shows a single object
representing the entire plot ...

library(ggplot2)
qplot(mpg, wt, data=mtcars, colour=cyl)
library(grid)
grid.ls()
layout

... BUT if we call grid.force(), we can see every grob, including the
grobs representing the legend (the children of 'guide-box.3-5-3-5') ...

grid.force()
grid.ls()
layout
background.1-6-6-1
spacer.4-3-4-3
panel.3-4-3-4
grill.gTree.15
panel.background..rect.6
panel.grid.minor.y..polyline.8
panel.grid.minor.x..polyline.10
panel.grid.major.y..polyline.12
panel.grid.major.x..polyline.14
geom_point.points.2
panel.border..zeroGrob.3
axis-l.3-3-3-3
axis.line.y..zeroGrob.27
axis
axis.1-1-1-1
GRID.text.24
axis.1-2-1-2
axis-b.4-4-4-4
axis.line.x..zeroGrob.20
axis
axis.1-1-1-1
axis.2-1-2-1
GRID.text.17
xlab.5-4-5-4
GRID.text.31
ylab.3-2-3-2
GRID.text.34
guide-box.3-5-3-5
guides.2-2-2-2
background.1-6-5-1
bar.4-2-4-2
label.4-4-4-4
title.2-5-2-2
ticks.4-2-4-2
title.2-4-2-4

References:

Section "Who benefits?" in ...

https://journal.r-project.org/archive/2013-2/murrell.pdf

Section "A more complex example" in ...

https://www.stat.auckland.ac.nz/~paul/Reports/CustomGrobs/custom-grob.html

Section "Implications for gtable" in ...

https://www.stat.auckland.ac.nz/~paul/R/customGridRedesign.pdf

On 03/02/16 02:43, Hadley Wickham wrote:

Can you remind me exactly what this did?


Reply to this email directly or view it on GitHub
#50 (comment).

Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

@hadley hadley merged commit 8d692fb into r-lib:master Feb 3, 2016
@hadley
Copy link
Member

hadley commented Feb 3, 2016

Thanks Paul! It's now merged ~3 years after the change in grid 😬

@pmur002
Copy link
Contributor Author

pmur002 commented Feb 3, 2016

Cool! Hope there's not too much blowback from the change.

On 04/02/16 07:28, Hadley Wickham wrote:

Thanks Paul! It's now merged ~3 years after the change in grid 😬


Reply to this email directly or view it on GitHub
#50 (comment).

Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

@hadley
Copy link
Member

hadley commented Feb 3, 2016

Me too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants