Skip to content

Commit afadca1

Browse files
committed
backward compatibility for ggplot_gtable()
1 parent ff12f37 commit afadca1

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ S3method(fortify,tbl)
5757
S3method(fortify,tbl_df)
5858
S3method(ggplot_add,default)
5959
S3method(ggplot_build,default)
60+
S3method(ggplot_gtable,default)
6061
S3method(grid.draw,absoluteGrob)
6162
S3method(grobHeight,absoluteGrob)
6263
S3method(grobHeight,zeroGrob)
@@ -439,6 +440,7 @@ export(ggproto)
439440
export(ggproto_parent)
440441
export(ggsave)
441442
export(ggtitle)
443+
export(gtable_ggplot)
442444
export(guide_axis)
443445
export(guide_axis_logticks)
444446
export(guide_axis_stack)

R/plot-build.R

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ layer_grob <- get_layer_grob
193193
#' to (e.g.) make the legend box 2 cm wide, or combine multiple plots into
194194
#' a single display, preserving aspect ratios across the plots.
195195
#'
196+
#' The `ggplot_gtable()` function is vestigial and the `gtable_ggplot()` function
197+
#' should be used instead.
198+
#'
196199
#' @seealso
197200
#' [print.ggplot()] and [benchplot()] for
198201
#' for functions that contain the complete set of steps for generating
@@ -203,12 +206,12 @@ layer_grob <- get_layer_grob
203206
#' @keywords internal
204207
#' @param data plot data generated by [ggplot_build()]
205208
#' @export
206-
ggplot_gtable <- S7::new_generic("ggplot_gtable", "data", function(data) {
209+
gtable_ggplot <- S7::new_generic("gtable_ggplot", "data", function(data) {
207210
attach_plot_env(data@plot@plot_env)
208211
S7::S7_dispatch()
209212
})
210213

211-
S7::method(ggplot_gtable, class_ggplot_built) <- function(data) {
214+
S7::method(gtable_ggplot, class_ggplot_built) <- function(data) {
212215
plot <- data@plot
213216
layout <- data@layout
214217
data <- data@data
@@ -309,6 +312,18 @@ S7::method(ggplot_gtable, class_ggplot_built) <- function(data) {
309312
plot_table
310313
}
311314

315+
# TODO: the S3 generic should be phased out once S7 is adopted more widely
316+
#' @rdname gtable_ggplot
317+
#' @export
318+
ggplot_gtable <- function(plot) {
319+
UseMethod("ggplot_gtable")
320+
}
321+
322+
#' @export
323+
ggplot_gtable.default <- function(plot) {
324+
gtable_ggplot(plot)
325+
}
326+
312327
#' Generate a ggplot2 plot grob.
313328
#'
314329
#' @param x ggplot2 object

man/ggplot_gtable.Rd renamed to man/gtable_ggplot.Rd

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)