Skip to content

Commit 5f49fb4

Browse files
jrnoldDana Paige Seidel
authored and
Dana Paige Seidel
committed
New examples for theme_*() (#2721)
1 parent 17b45f9 commit 5f49fb4

File tree

1 file changed

+39
-10
lines changed

1 file changed

+39
-10
lines changed

R/theme-defaults.r

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,45 @@
4949
#' }
5050
#'
5151
#' @examples
52-
#' p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg,
53-
#' colour = factor(gear))) + facet_wrap(~am)
54-
#' p + theme_gray() # the default
55-
#' p + theme_bw()
56-
#' p + theme_linedraw()
57-
#' p + theme_light()
58-
#' p + theme_dark()
59-
#' p + theme_minimal()
60-
#' p + theme_classic()
61-
#' p + theme_void()
52+
#' mtcars2 <- within(mtcars, {
53+
#' vs <- factor(vs, labels = c("V-shaped", "Straight"))
54+
#' am <- factor(am, labels = c("Automatic", "Manual"))
55+
#' cyl <- factor(cyl)
56+
#' gear <- factor(gear)
57+
#' })
58+
#'
59+
#' p1 <- ggplot(mtcars2) +
60+
#' geom_point(aes(x = wt, y = mpg, colour = gear)) +
61+
#' labs(title = "Fuel economy declines as weight increases",
62+
#' subtitle = "(1973-74)",
63+
#' caption = "Data from the 1974 Motor Trend US magazine.",
64+
#' tag = "Figure 1",
65+
#' x = "Weight (1000 lbs)",
66+
#' y = "Fuel economy (mpg)",
67+
#' colour = "Gears")
68+
#'
69+
#' p1 + theme_gray() # the default
70+
#' p1 + theme_bw()
71+
#' p1 + theme_linedraw()
72+
#' p1 + theme_light()
73+
#' p1 + theme_dark()
74+
#' p1 + theme_minimal()
75+
#' p1 + theme_classic()
76+
#' p1 + theme_void()
77+
#'
78+
#' # Theme examples with panels
79+
#' \donttest{
80+
#' p2 <- p1 + facet_grid(vs ~ am)
81+
#'
82+
#' p2 + theme_gray() # the default
83+
#' p2 + theme_bw()
84+
#' p2 + theme_linedraw()
85+
#' p2 + theme_light()
86+
#' p2 + theme_dark()
87+
#' p2 + theme_minimal()
88+
#' p2 + theme_classic()
89+
#' p2 + theme_void()
90+
#' }
6291
#' @name ggtheme
6392
#' @aliases NULL
6493
NULL

0 commit comments

Comments
 (0)