Skip to content

Commit 2f8d981

Browse files
committed
rename dict --> dictionary
1 parent 1c87bf0 commit 2f8d981

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

NEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ggplot2 (development version)
22

3-
* New argument `labs(dict)` to label based on variable name rather than based
4-
on aesthetic (@teunbrand, #5178)
3+
* New argument `labs(dictionary)` to label based on variable name rather than
4+
based on aesthetic (@teunbrand, #5178)
55
* `guide_bins()`, `guide_colourbar()` and `guide_coloursteps()` gain an `angle`
66
argument to overrule theme settings, similar to `guide_axis(angle)`
77
(@teunbrand, #4594).

R/labels.R

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ setup_plot_labels <- function(plot, layers, data) {
8484
))
8585
}
8686

87-
if (length(plot_labels$dict) > 0) {
88-
labels <- lapply(labels, revalue, replace = plot_labels$dict)
87+
if (length(plot_labels$dictionary) > 0) {
88+
labels <- lapply(labels, revalue, replace = plot_labels$dictionary)
8989
}
9090

9191
defaults(plot_labels, labels)
@@ -118,9 +118,10 @@ setup_plot_labels <- function(plot, layers, data) {
118118
#' bottom-right of the plot by default.
119119
#' @param tag The text for the tag label which will be displayed at the
120120
#' top-left of the plot by default.
121-
#' @param dict A named character vector to serve as dictionary. Automatically
122-
#' derived labels, such as those based on variables will be matched with
123-
#' `names(dict)` and replaced by the matching entry in `dict`.
121+
#' @param dictionary A named character vector to serve as dictionary.
122+
#' Automatically derived labels, such as those based on variables will
123+
#' be matched with `names(dictionary)` and replaced by the matching
124+
#' entry in `dictionary`.
124125
#' @param alt,alt_insight Text used for the generation of alt-text for the plot.
125126
#' See [get_alt_text] for examples. `alt` can also be a function that
126127
#' takes the plot as input and returns text as output. `alt` also accepts
@@ -161,12 +162,12 @@ setup_plot_labels <- function(plot, layers, data) {
161162
#' labs(title = "title") +
162163
#' labs(title = NULL)
163164
labs <- function(..., title = waiver(), subtitle = waiver(), caption = waiver(),
164-
tag = waiver(), dict = waiver(), alt = waiver(),
165+
tag = waiver(), dictionary = waiver(), alt = waiver(),
165166
alt_insight = waiver()) {
166167
# .ignore_empty = "all" is needed to allow trailing commas, which is NOT a trailing comma for dots_list() as it's in ...
167168
args <- dots_list(..., title = title, subtitle = subtitle, caption = caption,
168-
tag = tag, alt = allow_lambda(alt), alt_insight = alt_insight, dict = dict,
169-
.ignore_empty = "all")
169+
tag = tag, alt = allow_lambda(alt), alt_insight = alt_insight,
170+
dictionary = dictionary, .ignore_empty = "all")
170171

171172
is_waive <- vapply(args, is.waive, logical(1))
172173
args <- args[!is_waive]

man/labs.Rd

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-labels.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ test_that("label dictionaries work", {
271271

272272
p <- ggplot(mtcars, aes(disp, mpg, shape = factor(cyl), size = drat)) +
273273
geom_point() +
274-
labs(dict = c(
274+
labs(dictionary = c(
275275
disp = "Displacement",
276276
mpg = "Miles per gallon",
277277
`factor(cyl)` = "Number of cylinders",

0 commit comments

Comments
 (0)