Skip to content

Commit a8f73e0

Browse files
committed
Merge pull request #976 from jiho/feature/theme_void
New theme_void(), completely empty
2 parents 2b6b986 + 5f0a130 commit a8f73e0

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ export(theme_linedraw)
401401
export(theme_minimal)
402402
export(theme_set)
403403
export(theme_update)
404+
export(theme_void)
404405
export(update_geom_defaults)
405406
export(update_labels)
406407
export(update_stat_defaults)

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* New `theme_void()`, which is completely empty. Useful for plots with non
2+
standard coordinates or for producing numerical drawings with R. (@jiho, #976)
3+
14
* Create correct legend for continuous color even if there is only one color
25
(@krlmlr, #943)
36

R/theme-defaults.r

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
#' \item{\code{theme_classic}}{
3636
#' A classic-looking theme, with x and y axis lines and no gridlines.}
3737
#'
38+
#' \item{\code{theme_void}}{
39+
#' A completely empty theme.}
40+
#'
3841
#' }
3942
#'
4043
#' @examples
@@ -48,6 +51,7 @@
4851
#' p + theme_light()
4952
#' p + theme_minimal()
5053
#' p + theme_classic()
54+
#' p + theme_void()
5155
#'
5256
#' @name ggtheme
5357
NULL
@@ -214,3 +218,17 @@ theme_dark <- function(base_size = 12, base_family = "") {
214218
strip.text.y = element_text(colour = "white", angle = -90)
215219
)
216220
}
221+
222+
#' @export
223+
#' @rdname ggtheme
224+
theme_void <- function(base_size = 12, base_family = "") {
225+
theme(
226+
# Use only inherited elements and make everything blank
227+
line = element_blank(),
228+
rect = element_blank(),
229+
text = element_blank(),
230+
plot.margin = unit(c(0, 0, 0, 0), "lines"),
231+
232+
complete = TRUE
233+
)
234+
}

man/ggtheme.Rd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
\alias{theme_light}
1111
\alias{theme_linedraw}
1212
\alias{theme_minimal}
13+
\alias{theme_void}
1314
\title{ggplot2 themes}
1415
\usage{
1516
theme_grey(base_size = 12, base_family = "")
@@ -27,6 +28,8 @@ theme_minimal(base_size = 12, base_family = "")
2728
theme_classic(base_size = 12, base_family = "")
2829

2930
theme_dark(base_size = 12, base_family = "")
31+
32+
theme_void(base_size = 12, base_family = "")
3033
}
3134
\arguments{
3235
\item{base_size}{base font size}
@@ -67,6 +70,9 @@ A minimalistic theme with no background annotations.}
6770
\item{\code{theme_classic}}{
6871
A classic-looking theme, with x and y axis lines and no gridlines.}
6972

73+
\item{\code{theme_void}}{
74+
A completely empty theme.}
75+
7076
}
7177
}
7278
\examples{
@@ -80,5 +86,6 @@ p + theme_linedraw()
8086
p + theme_light()
8187
p + theme_minimal()
8288
p + theme_classic()
89+
p + theme_void()
8390
}
8491

0 commit comments

Comments
 (0)