Skip to content

New theme_void(), completely empty #976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2015
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
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
18 changes: 18 additions & 0 deletions R/theme-defaults.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -48,6 +51,7 @@
#' p + theme_light()
#' p + theme_minimal()
#' p + theme_classic()
#' p + theme_void()
#'
#' @name ggtheme
NULL
Expand Down Expand Up @@ -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
)
}
7 changes: 7 additions & 0 deletions man/ggtheme.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "")
Expand All @@ -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}
Expand Down Expand Up @@ -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{
Expand All @@ -80,5 +86,6 @@ p + theme_linedraw()
p + theme_light()
p + theme_minimal()
p + theme_classic()
p + theme_void()
}