Skip to content

Commit

Permalink
deleting part of plot_grid vignette that doesn't work anymore.
Browse files Browse the repository at this point in the history
  • Loading branch information
clauswilke committed Mar 6, 2016
1 parent 1a25dd2 commit 81687f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
9 changes: 8 additions & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
* local OS X install x86_64-apple-darwin13.4.0 (64-bit), R 3.2.3

## R CMD check results
There were no ERRORs, WARNINGs, or NOTEs.
There were no ERRORs or WARNINGs.

There is one NOTE, about spelling:
Possibly mis-spelled words in DESCRIPTION:
Wilke (11:55)
Wilke's (12:45)

Both spellings are correct.

## Downstream dependencies
None exist at this time.
19 changes: 0 additions & 19 deletions vignettes/plot_grid.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,6 @@ plot_grid(plot.iris, plot.mpg, labels = "AUTO", ncol = 1,
align = 'v') # aligning does not work here
```

In cases where `plot_grid()` cannot automatcially align plots, you can still align them manually if you have some knowledge of gtable, the internal layouting mechanism used by ggplot2. You simply have to convert both graphs into gtable objects and then adjust the relevant widths or heights. For the plot from the previous example, for example, you could do the following:
```{r, message=FALSE, fig.width=4.25, fig.height=5.1}
require(grid) # for unit.pmax()
g.iris <- ggplotGrob(plot.iris) # convert to gtable
g.mpg <- ggplotGrob(plot.mpg) # convert to gtable
iris.widths <- g.iris$widths[1:3] # extract the first three widths,
# corresponding to left margin, y lab, and y axis
mpg.widths <- g.mpg$widths[1:3] # same for mpg plot
max.widths <- unit.pmax(iris.widths, mpg.widths) # calculate maximum widths
g.iris$widths[1:3] <- max.widths # assign max. widths to iris gtable
g.mpg$widths[1:3] <- max.widths # assign max widths to mpg gtable
# plot_grid() can work directly with gtables, so this works
plot_grid(g.iris, g.mpg, labels = "AUTO", ncol = 1)
```

Notice how now the y axes in plots A and B are located at exactly the same horizontal position.

# Fine-tuning the plot appearance

You can adjust the label size via the `label_size` option. Default is 14, so larger values will make the labels larger and smaller values will make them smaller:
Expand Down
2 changes: 1 addition & 1 deletion vignettes/shared_legends.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ legend_b <- grobs[[which(sapply(grobs, function(x) x$name) == "guide-box")]]
# add the legend underneath the row we made earlier. Give it 10% of the height
# of one plot (via rel_heights).
p <- plot_grid( prow, legend_b, ncol = 1, rel_heights = c(1, .1))
p <- plot_grid( prow, legend_b, ncol = 1, rel_heights = c(1, .2))
p
```

Expand Down

0 comments on commit 81687f3

Please sign in to comment.