diff --git a/NAMESPACE b/NAMESPACE index 9bdf0662a5..488256708d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -401,6 +401,7 @@ export(theme_linedraw) export(theme_minimal) export(theme_set) export(theme_update) +export(theme_void) export(update_geom_defaults) export(update_labels) export(update_stat_defaults) diff --git a/NEWS b/NEWS index 7a0a85ceea..a011a96cbf 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +* New `theme_void()`, which is completely empty. Useful for plots with non + standard coordinates or for producing numerical drawings with R. (@jiho, #976) + * Create correct legend for continuous color even if there is only one color (@krlmlr, #943) diff --git a/R/theme-defaults.r b/R/theme-defaults.r index bf4226b41d..226e957e7c 100644 --- a/R/theme-defaults.r +++ b/R/theme-defaults.r @@ -35,6 +35,9 @@ #' \item{\code{theme_classic}}{ #' A classic-looking theme, with x and y axis lines and no gridlines.} #' +#' \item{\code{theme_void}}{ +#' A completely empty theme.} +#' #' } #' #' @examples @@ -48,6 +51,7 @@ #' p + theme_light() #' p + theme_minimal() #' p + theme_classic() +#' p + theme_void() #' #' @name ggtheme NULL @@ -214,3 +218,17 @@ theme_dark <- function(base_size = 12, base_family = "") { strip.text.y = element_text(colour = "white", angle = -90) ) } + +#' @export +#' @rdname ggtheme +theme_void <- function(base_size = 12, base_family = "") { + theme( + # Use only inherited elements and make everything blank + line = element_blank(), + rect = element_blank(), + text = element_blank(), + plot.margin = unit(c(0, 0, 0, 0), "lines"), + + complete = TRUE + ) +} diff --git a/man/ggtheme.Rd b/man/ggtheme.Rd index 177cac0bf2..cca7dcff89 100644 --- a/man/ggtheme.Rd +++ b/man/ggtheme.Rd @@ -10,6 +10,7 @@ \alias{theme_light} \alias{theme_linedraw} \alias{theme_minimal} +\alias{theme_void} \title{ggplot2 themes} \usage{ theme_grey(base_size = 12, base_family = "") @@ -27,6 +28,8 @@ theme_minimal(base_size = 12, base_family = "") theme_classic(base_size = 12, base_family = "") theme_dark(base_size = 12, base_family = "") + +theme_void(base_size = 12, base_family = "") } \arguments{ \item{base_size}{base font size} @@ -67,6 +70,9 @@ A minimalistic theme with no background annotations.} \item{\code{theme_classic}}{ A classic-looking theme, with x and y axis lines and no gridlines.} +\item{\code{theme_void}}{ +A completely empty theme.} + } } \examples{ @@ -80,5 +86,6 @@ p + theme_linedraw() p + theme_light() p + theme_minimal() p + theme_classic() +p + theme_void() }