Skip to content

Commit 1935001

Browse files
committed
Merge pull request #1018 from jiho/feature/theme_dark
Dark theme
2 parents 380c3b1 + a170a46 commit 1935001

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ export(stat_ydensity)
392392
export(theme)
393393
export(theme_bw)
394394
export(theme_classic)
395+
export(theme_dark)
395396
export(theme_get)
396397
export(theme_gray)
397398
export(theme_grey)

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ ggplot2 1.0.0
5555

5656
NEW FEATURES
5757

58+
* New dark-backgrounded theme, `theme_dark()`, meant to make colours pop out
59+
(@jiho, #1018)
60+
5861
* New coordinate system for small scale maps. `coord_quickmap()` computes and
5962
sets the correct aspect ratio between one degree of latitude and one degree
6063
of longitude at the centre of the plotted region. It does not perform full

R/theme-defaults.r

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#' A theme similar to \code{theme_linedraw} but with light grey lines and axes,
2727
#' to direct more attention towards the data.}
2828
#'
29+
#' \item{\code{theme_dark}}{
30+
#' The dark cousin of \code{theme_light}, with similar line sizes but a dark background. Useful to make thin coloured lines pop out.}
31+
#'
2932
#' \item{\code{theme_minimal}}{
3033
#' A minimalistic theme with no background annotations.}
3134
#'
@@ -194,3 +197,20 @@ theme_classic <- function(base_size = 12, base_family = ""){
194197
legend.key = element_blank()
195198
)
196199
}
200+
201+
#' @export
202+
#' @rdname ggtheme
203+
theme_dark <- function(base_size = 12, base_family = "") {
204+
# Starts with theme_grey and then modify some parts
205+
theme_grey(base_size = base_size, base_family = base_family) %+replace%
206+
theme(
207+
axis.ticks = element_line(colour = "grey40", size = 0.25),
208+
legend.key = element_rect(fill = "grey50", colour = "grey40", size=0.25),
209+
panel.background = element_rect(fill = "grey50", colour = NA),
210+
panel.grid.major = element_line(colour = "grey40", size = 0.25),
211+
panel.grid.minor = element_line(colour = "grey45", size = 0.125),
212+
strip.background = element_rect(fill = "grey20", colour = NA),
213+
strip.text.x = element_text(colour = "white"),
214+
strip.text.y = element_text(colour = "white", angle = -90)
215+
)
216+
}

man/ggtheme.Rd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
\alias{ggtheme}
55
\alias{theme_bw}
66
\alias{theme_classic}
7+
\alias{theme_dark}
78
\alias{theme_gray}
89
\alias{theme_grey}
910
\alias{theme_light}
@@ -24,6 +25,8 @@ theme_light(base_size = 12, base_family = "")
2425
theme_minimal(base_size = 12, base_family = "")
2526

2627
theme_classic(base_size = 12, base_family = "")
28+
29+
theme_dark(base_size = 12, base_family = "")
2730
}
2831
\arguments{
2932
\item{base_size}{base font size}
@@ -55,6 +58,9 @@ may refuse.}
5558
A theme similar to \code{theme_linedraw} but with light grey lines and axes,
5659
to direct more attention towards the data.}
5760

61+
\item{\code{theme_dark}}{
62+
The dark cousin of \code{theme_light}, with similar line sizes but a dark background. Useful to make thin coloured lines pop out.}
63+
5864
\item{\code{theme_minimal}}{
5965
A minimalistic theme with no background annotations.}
6066

0 commit comments

Comments
 (0)