Skip to content

Commit 89c2cf4

Browse files
committed
Move theme_dark next to theme_light in the code
They are related and their examples are in this order
1 parent 15fbd62 commit 89c2cf4

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

R/theme-defaults.r

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,31 @@ theme_light <- function(base_size = 11, base_family = "") {
218218

219219
}
220220

221+
#' @export
222+
#' @rdname ggtheme
223+
theme_dark <- function(base_size = 11, base_family = "") {
224+
# Starts with theme_grey and then modify some parts
225+
theme_grey(base_size = base_size, base_family = base_family) %+replace%
226+
theme(
227+
# dark panel
228+
panel.background = element_rect(fill = "grey50", colour = NA),
229+
# inverse grid lines contrast compared to theme_grey
230+
# make them thinner and try to keep the same visual contrast as in theme_light
231+
panel.grid.major = element_line(colour = "grey42", size = 0.25),
232+
panel.grid.minor = element_line(colour = "grey42", size = 0.125),
233+
234+
# match axes ticks thickness to gridlines
235+
axis.ticks = element_line(colour = "grey20", size = 0.25),
236+
237+
# match legend key to panel.background
238+
legend.key = element_rect(fill = "grey50", colour = NA),
239+
240+
# dark strips with light text (inverse contrast compared to theme_grey)
241+
strip.background = element_rect(fill = "grey15", colour = NA),
242+
strip.text = element_text(colour = "grey90", size = rel(0.8))
243+
)
244+
}
245+
221246
#' @export
222247
#' @rdname ggtheme
223248
theme_minimal <- function(base_size = 11, base_family = "") {
@@ -258,31 +283,6 @@ theme_classic <- function(base_size = 11, base_family = ""){
258283
)
259284
}
260285

261-
#' @export
262-
#' @rdname ggtheme
263-
theme_dark <- function(base_size = 11, base_family = "") {
264-
# Starts with theme_grey and then modify some parts
265-
theme_grey(base_size = base_size, base_family = base_family) %+replace%
266-
theme(
267-
# dark panel
268-
panel.background = element_rect(fill = "grey50", colour = NA),
269-
# inverse grid lines contrast compared to theme_grey
270-
# make them thinner and try to keep the same visual contrast as in theme_light
271-
panel.grid.major = element_line(colour = "grey42", size = 0.25),
272-
panel.grid.minor = element_line(colour = "grey42", size = 0.125),
273-
274-
# match axes ticks thickness to gridlines
275-
axis.ticks = element_line(colour = "grey20", size = 0.25),
276-
277-
# match legend key to panel.background
278-
legend.key = element_rect(fill = "grey50", colour = NA),
279-
280-
# dark strips with light text (inverse contrast compared to theme_grey)
281-
strip.background = element_rect(fill = "grey15", colour = NA),
282-
strip.text = element_text(colour = "grey90", size = rel(0.8))
283-
)
284-
}
285-
286286
#' @export
287287
#' @rdname ggtheme
288288
theme_void <- function(base_size = 11, base_family = "") {

0 commit comments

Comments
 (0)