From 8c932a659bdbaac7b1b423e5390d244fb606baa1 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 25 Apr 2025 11:15:48 +0200 Subject: [PATCH] add new examples --- R/theme.R | 15 +++++++++++++++ man/theme.Rd | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/R/theme.R b/R/theme.R index 8ad12765a0..755dc02d7d 100644 --- a/R/theme.R +++ b/R/theme.R @@ -319,6 +319,21 @@ #' # as in the facet_wrap the default strip.position is "top" #' p3 + theme(strip.text.x.top = element_text(colour = "white", face = "bold")) #' p3 + theme(panel.spacing = unit(1, "lines")) +#' +#' # Colours ------------------------------------------------------------------- +#' +#' p4 <- ggplot(mtcars, aes(wt, mpg)) + +#' geom_point() + +#' annotate(label = "Text Annotation", x = 5, y = 30, geom = "text") +#' +#' # You can use the 'ink' setting to set colour defaults for all layers +#' p4 + theme(geom = element_geom(ink = "dodgerblue")) +#' # Alternate colours are derived from the 'accent' and 'paper' settings +#' p4 + geom_smooth(method = "lm", formula = y ~ x) + +#' theme(geom = element_geom(accent = "tomato", paper = "orchid")) +#' # You can also set default palettes in the theme +#' p4 + aes(colour = drat) + +#' theme(palette.colour.continuous = c("white", "pink", "hotpink")) #' } theme <- function(..., line, diff --git a/man/theme.Rd b/man/theme.Rd index 2766a3f8ca..1a435c3ba4 100644 --- a/man/theme.Rd +++ b/man/theme.Rd @@ -516,6 +516,21 @@ p3 + theme(strip.text.x = element_text(colour = "white", face = "bold")) # as in the facet_wrap the default strip.position is "top" p3 + theme(strip.text.x.top = element_text(colour = "white", face = "bold")) p3 + theme(panel.spacing = unit(1, "lines")) + +# Colours ------------------------------------------------------------------- + +p4 <- ggplot(mtcars, aes(wt, mpg)) + + geom_point() + + annotate(label = "Text Annotation", x = 5, y = 30, geom = "text") + +# You can use the 'ink' setting to set colour defaults for all layers +p4 + theme(geom = element_geom(ink = "dodgerblue")) +# Alternate colours are derived from the 'accent' and 'paper' settings +p4 + geom_smooth(method = "lm", formula = y ~ x) + + theme(geom = element_geom(accent = "tomato", paper = "orchid")) +# You can also set default palettes in the theme +p4 + aes(colour = drat) + + theme(palette.colour.continuous = c("white", "pink", "hotpink")) } } \seealso{