Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions R/ggplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

ggplot_build_set <- function() {
if (!is_installed("ggplot2")) return(NULL)
# Alternative update method if we're dealing with S7
if ("class_ggplot" %in% getNamespaceExports("ggplot2")) {
.globals$ggplot_build <- getFromNamespace("build_ggplot", "ggplot2")
registerS3method("ggplot_build", "ggplot", ggthematic_build, asNamespace("ggplot2"))
return(NULL)
}
ggplot_build_restore()
# Note that assignInNamespace() does S3 method registration, but to
# find the relevant generic, it looks in the parent.frame()...
Expand All @@ -28,6 +34,12 @@ ggplot_build_set <- function() {
}

ggplot_build_restore <- function() {
# Alternative update method if we're dealing with S7
if ("class_ggplot" %in% getNamespaceExports("ggplot2")) {
dummy_method <- function(plot, ...) NextMethod()
registerS3method("ggplot_build", "ggplot", dummy_method, asNamespace("ggplot2"))
return(NULL)
}
if (is.function(.globals$ggplot_build)) {
ggplot_build <- getFromNamespace("ggplot_build", "ggplot2")
assign_in_namespace <- assignInNamespace
Expand Down Expand Up @@ -84,7 +96,12 @@ ggthematic_build <- function(p, ggplot_build = NULL, theme = NULL) {
)

# Remember defaults
user_defaults <- lapply(geoms, function(geom) geom$default_aes)
if ("get_geom_defaults" %in% getNamespaceExports("ggplot2")) {
get_geom_defaults <- get("get_geom_defaults", asNamespace("ggplot2"))
} else {
get_geom_defaults <- function(geom, ...) geom$default_aes
}
user_defaults <- lapply(geoms, get_geom_defaults, theme = theme)

# Modify defaults
Map(function(geom, user_default) {
Expand Down Expand Up @@ -200,7 +217,15 @@ ggthematic_build <- function(p, ggplot_build = NULL, theme = NULL) {
# setting them here would disrupt that mechanism.
restore <- c("hjust", "vjust", "margin")
for (name in c("title", "legend.title", "legend.text")) {
theme_final[[name]][restore] <- p$theme[[name]][restore] %||% list(NULL)
if (ggplot2::is_theme_element(theme_final[[name]], "blank")) {
next
}
if (ggplot2::is_theme_element(p$theme[[name]], "blank")) {
value <- list(NULL)
} else {
value <- p$theme[[name]][restore] %||% list(NULL)
}
theme_final[[name]][restore] <- value
}
p$theme <- theme_final

Expand Down
Binary file modified tests/testthat/CairoPNG/tests/testthat/_snaps/mac/mytest/001_.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testthat/CairoPNG/tests/testthat/_snaps/mac/mytest/002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
286 changes: 143 additions & 143 deletions tests/testthat/_snaps/ggplot/geomabline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
186 changes: 93 additions & 93 deletions tests/testthat/_snaps/ggplot/geombar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
335 changes: 164 additions & 171 deletions tests/testthat/_snaps/ggplot/geombin2d.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
260 changes: 130 additions & 130 deletions tests/testthat/_snaps/ggplot/geombox.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
268 changes: 134 additions & 134 deletions tests/testthat/_snaps/ggplot/geomcount.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
206 changes: 103 additions & 103 deletions tests/testthat/_snaps/ggplot/geomcurve.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
117 changes: 59 additions & 58 deletions tests/testthat/_snaps/ggplot/geomdensity.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
231 changes: 118 additions & 113 deletions tests/testthat/_snaps/ggplot/geomdensitycolor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
200 changes: 100 additions & 100 deletions tests/testthat/_snaps/ggplot/geomdotplot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 65 additions & 65 deletions tests/testthat/_snaps/ggplot/geomerror.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 62 additions & 64 deletions tests/testthat/_snaps/ggplot/geomerrorbar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
616 changes: 308 additions & 308 deletions tests/testthat/_snaps/ggplot/geomhistogram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
548 changes: 274 additions & 274 deletions tests/testthat/_snaps/ggplot/geomjitter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
848 changes: 424 additions & 424 deletions tests/testthat/_snaps/ggplot/geomlabel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
160 changes: 80 additions & 80 deletions tests/testthat/_snaps/ggplot/geomline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
256 changes: 128 additions & 128 deletions tests/testthat/_snaps/ggplot/geomline2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,098 changes: 1,049 additions & 1,049 deletions tests/testthat/_snaps/ggplot/geompoint.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
198 changes: 99 additions & 99 deletions tests/testthat/_snaps/ggplot/geompoint2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
206 changes: 103 additions & 103 deletions tests/testthat/_snaps/ggplot/geompointcolor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 36 additions & 38 deletions tests/testthat/_snaps/ggplot/geompolygon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
152 changes: 75 additions & 77 deletions tests/testthat/_snaps/ggplot/geompolygon2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
154 changes: 77 additions & 77 deletions tests/testthat/_snaps/ggplot/geomribbon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
278 changes: 139 additions & 139 deletions tests/testthat/_snaps/ggplot/geomrug.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
274 changes: 137 additions & 137 deletions tests/testthat/_snaps/ggplot/geomrug2.svg

Large diffs are not rendered by default.

2,410 changes: 1,196 additions & 1,214 deletions tests/testthat/_snaps/ggplot/geomsmooth.svg

Large diffs are not rendered by default.

720 changes: 360 additions & 360 deletions tests/testthat/_snaps/ggplot/geomsmooth2.svg

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions tests/testthat/_snaps/ggplot/geomspoke.svg

Large diffs are not rendered by default.

782 changes: 391 additions & 391 deletions tests/testthat/_snaps/ggplot/geomtext.svg

Large diffs are not rendered by default.

138 changes: 69 additions & 69 deletions tests/testthat/_snaps/ggplot/geomtile.svg

Large diffs are not rendered by default.

112 changes: 56 additions & 56 deletions tests/testthat/_snaps/ggplot/geomviolin.svg

Large diffs are not rendered by default.

272 changes: 136 additions & 136 deletions tests/testthat/_snaps/ggplot/qualitative-color.svg

Large diffs are not rendered by default.

202 changes: 102 additions & 100 deletions tests/testthat/_snaps/ggplot/qualitative-fill.svg

Large diffs are not rendered by default.

210 changes: 105 additions & 105 deletions tests/testthat/_snaps/ggplot/sequential-color.svg

Large diffs are not rendered by default.

182 changes: 91 additions & 91 deletions tests/testthat/_snaps/ggplot/sequential-fill.svg

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions tests/testthat/_snaps/ggthemes/axis-interitance-distant.svg

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions tests/testthat/_snaps/ggthemes/axis-interitance-distant2.svg

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions tests/testthat/_snaps/ggthemes/axis-interitance.svg

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions tests/testthat/_snaps/ggthemes/base.svg

Large diffs are not rendered by default.

86 changes: 43 additions & 43 deletions tests/testthat/_snaps/ggthemes/calc.svg

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions tests/testthat/_snaps/ggthemes/classic.svg

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions tests/testthat/_snaps/ggthemes/clean.svg

Large diffs are not rendered by default.

434 changes: 217 additions & 217 deletions tests/testthat/_snaps/ggthemes/excel-new.svg

Large diffs are not rendered by default.

452 changes: 226 additions & 226 deletions tests/testthat/_snaps/ggthemes/fivethirtyeight.svg

Large diffs are not rendered by default.

112 changes: 56 additions & 56 deletions tests/testthat/_snaps/ggthemes/foundation.svg

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions tests/testthat/_snaps/ggthemes/gdocs.svg

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions tests/testthat/_snaps/ggthemes/ggtheme-minimal-off.svg
194 changes: 97 additions & 97 deletions tests/testthat/_snaps/ggthemes/ggtheme-minimal.svg

Large diffs are not rendered by default.

188 changes: 94 additions & 94 deletions tests/testthat/_snaps/ggthemes/ggtheme-void.svg

Large diffs are not rendered by default.

Loading
Loading