Skip to content

Dark theme #1018

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 3 commits into from
Jun 11, 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 @@ -397,6 +397,7 @@ export(theme)
export(theme_blank)
export(theme_bw)
export(theme_classic)
export(theme_dark)
export(theme_get)
export(theme_gray)
export(theme_grey)
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ ggplot2 1.0.0

NEW FEATURES

* New dark-backgrounded theme, `theme_dark()`, meant to make colours pop out
(@jiho, #1018)

* New coordinate system for small scale maps. `coord_quickmap()` computes and
sets the correct aspect ratio between one degree of latitude and one degree
of longitude at the centre of the plotted region. It does not perform full
Expand Down
20 changes: 20 additions & 0 deletions R/theme-defaults.r
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#' A theme similar to \code{theme_linedraw} but with light grey lines and axes,
#' to direct more attention towards the data.}
#'
#' \item{\code{theme_dark}}{
#' The dark cousin of \code{theme_light}, with similar line sizes but a dark background. Useful to make thin coloured lines pop out.}
#'
#' \item{\code{theme_minimal}}{
#' A minimalistic theme with no background annotations.}
#'
Expand Down Expand Up @@ -194,3 +197,20 @@ theme_classic <- function(base_size = 12, base_family = ""){
legend.key = element_blank()
)
}

#' @export
#' @rdname ggtheme
theme_dark <- function(base_size = 12, base_family = "") {
# Starts with theme_grey and then modify some parts
theme_grey(base_size = base_size, base_family = base_family) %+replace%
theme(
axis.ticks = element_line(colour = "grey40", size = 0.25),
legend.key = element_rect(fill = "grey50", colour = "grey40", size=0.25),
panel.background = element_rect(fill = "grey50", colour = NA),
panel.grid.major = element_line(colour = "grey40", size = 0.25),
panel.grid.minor = element_line(colour = "grey45", size = 0.125),
strip.background = element_rect(fill = "grey20", colour = NA),
strip.text.x = element_text(colour = "white"),
strip.text.y = element_text(colour = "white", angle = -90)
)
}
6 changes: 6 additions & 0 deletions man/ggtheme.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
\alias{ggtheme}
\alias{theme_bw}
\alias{theme_classic}
\alias{theme_dark}
\alias{theme_gray}
\alias{theme_grey}
\alias{theme_light}
Expand All @@ -23,6 +24,8 @@ theme_light(base_size = 12, base_family = "")
theme_minimal(base_size = 12, base_family = "")

theme_classic(base_size = 12, base_family = "")

theme_dark(base_size = 12, base_family = "")
}
\arguments{
\item{base_size}{base font size}
Expand Down Expand Up @@ -54,6 +57,9 @@ may refuse.}
A theme similar to \code{theme_linedraw} but with light grey lines and axes,
to direct more attention towards the data.}

\item{\code{theme_dark}}{
The dark cousin of \code{theme_light}, with similar line sizes but a dark background. Useful to make thin coloured lines pop out.}

\item{\code{theme_minimal}}{
A minimalistic theme with no background annotations.}

Expand Down