Skip to content

Commit 39303f5

Browse files
committed
append old ggplot classes
1 parent 84bc9d4 commit 39303f5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

R/plot-build.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ S7::method(build_ggplot, class_ggplot) <- function(plot, ...) {
131131
# Consolidate alt-text
132132
plot@labels$alt <- get_alt_text(plot)
133133

134-
class_ggplot_built(data = data, layout = layout, plot = plot)
134+
build <- class_ggplot_built(data = data, layout = layout, plot = plot)
135+
class(build) <- union(c("ggplot2::ggplot_built", "ggplot_built"), class(build))
136+
build
135137
}
136138

137139
# TODO: the S3 generic should be phased out once S7 is adopted more widely

R/plot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ S7::method(ggplot, S7::class_any) <- function(
131131
mapping = mapping,
132132
plot_env = environment
133133
)
134-
class(p) <- union("ggplot", class(p))
134+
class(p) <- union(union(c("ggplot2::ggplot", "ggplot"), class(p)), "gg")
135135

136136
set_last_plot(p)
137137
p

0 commit comments

Comments
 (0)