Skip to content

Commit 47b37cf

Browse files
committed
propagate throughout
1 parent 5687cbd commit 47b37cf

File tree

8 files changed

+28
-25
lines changed

8 files changed

+28
-25
lines changed

R/guide-legend.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#' Arguments that apply to a single legend are respected, most of which have
2020
#' the `legend`-prefix. Arguments that apply to combined legends
2121
#' (the legend box) are ignored, including `legend.position`,
22-
#' `legend.justification.*`, `legend.location` and `legend.box.*`.
22+
#' `legend.just.*`, `legend.location` and `legend.box.*`.
2323
#' @param position A character string indicating where the legend should be
2424
#' placed relative to the plot panels.
2525
#' One of "top", "right", "bottom", "left", or "inside".
@@ -179,7 +179,7 @@ GuideLegend <- ggproto(
179179
key = "legend.key",
180180
key_height = "legend.key.height",
181181
key_width = "legend.key.width",
182-
key_just = "legend.key.justification",
182+
key_just = "legend.key.just",
183183
text = "legend.text",
184184
theme.title = "legend.title",
185185
spacing_x = "legend.key.spacing.x",

R/guides-.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ Guides <- ggproto(
500500
}
501501

502502
# prepare the position of inside legends
503-
default_inside_just <- calc_element("legend.justification.inside", theme)
503+
default_inside_just <- calc_element("legend.just.inside", theme)
504504
default_inside_position <- calc_element("legend.position.inside", theme)
505505

506506
groups <- data_frame0(
@@ -514,9 +514,9 @@ Guides <- ggproto(
514514
for (i in which(positions == "inside")) {
515515
# the actual inside position and justification can be set in each guide
516516
# by `theme` argument, here, we won't use `calc_element()` which will
517-
# use inherits from `legend.justification` or `legend.position`, we only
517+
# use inherits from `legend.just` or `legend.position`, we only
518518
# follow the inside elements from the guide theme
519-
just <- params[[i]]$theme[["legend.justification.inside"]]
519+
just <- params[[i]]$theme[["legend.just.inside"]]
520520
just <- valid.just(just %||% default_inside_just)
521521
coord <- params[[i]]$theme[["legend.position.inside"]]
522522
coord <- coord %||% default_inside_position %||% just
@@ -541,7 +541,7 @@ Guides <- ggproto(
541541
if (position == "inside") {
542542
adjust <- theme(
543543
legend.position.inside = groups$key$coords[[i]],
544-
legend.justification.inside = groups$key$justs[[i]]
544+
legend.just.inside = groups$key$justs[[i]]
545545
)
546546
}
547547
adjust <- add_theme(theme, adjust, "internal theme settings")
@@ -615,7 +615,7 @@ Guides <- ggproto(
615615
stretch_y <- any(unlist(lapply(heights, unitType)) == "null")
616616

617617
# Global justification of the complete legend box
618-
global_just <- paste0("legend.justification.", position)
618+
global_just <- paste0("legend.just.", position)
619619
global_just <- valid.just(calc_element(global_just, theme))
620620

621621
if (position == "inside") {

R/theme-defaults.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ theme_grey <- function(base_size = 11, base_family = "",
218218
legend.ticks.length = rel(0.2),
219219
legend.position = "right",
220220
legend.direction = NULL,
221-
legend.justification = "center",
221+
legend.just = "center",
222222
legend.box = NULL,
223223
legend.box.margin = margin_auto(0),
224224
legend.box.background = element_blank(),
@@ -707,7 +707,7 @@ theme_test <- function(base_size = 11, base_family = "",
707707
legend.ticks.length = rel(0.2),
708708
legend.position = "right",
709709
legend.direction = NULL,
710-
legend.justification = "center",
710+
legend.just = "center",
711711
legend.box = NULL,
712712
legend.box.margin = margin_auto(0, unit = "cm"),
713713
legend.box.background = element_blank(),

R/theme-sub.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ theme_sub_legend <- function(
105105
spacing, spacing.x, spacing.y, margin,
106106
# Seys
107107
key, key.size, key.height, key.width, key.spacing, key.spacing.x,
108-
key.spacing.y, key.justification,
108+
key.spacing.y, key.just,
109109
# Settings
110110
byrow, position, direction, location, position.inside,
111111
# Justification

tests/testthat/_snaps/theme.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@
150150
[17] "axis.minor.ticks.r" "axis.ticks.length.theta"
151151
[19] "axis.ticks.length.r" "axis.minor.ticks.length.theta"
152152
[21] "axis.minor.ticks.length.r" "axis.line.theta"
153-
[23] "axis.line.r" "complete"
154-
[25] "validate"
153+
[23] "axis.line.r" "legend.just"
154+
[25] "legend.just.top" "legend.just.bottom"
155+
[27] "legend.just.left" "legend.just.right"
156+
[29] "legend.just.inside" "complete"
157+
[31] "validate"
155158

tests/testthat/test-guide-legend.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ test_that("absent titles don't take up space", {
186186
legend.title = element_blank(),
187187
legend.margin = margin(),
188188
legend.position = "top",
189-
legend.justification = "left",
189+
legend.just = "left",
190190
legend.key = element_rect(colour = "black"),
191191
axis.line = element_line(colour = "black")
192192
)
@@ -221,7 +221,7 @@ test_that("legend.byrow works in `guide_legend()`", {
221221
expect_doppelganger("legend.byrow = TRUE", p)
222222
})
223223

224-
test_that("legend.key.justification works as intended", {
224+
test_that("legend.key.just works as intended", {
225225

226226
p <- ggplot(mtcars, aes(mpg, disp, colour = factor(cyl), size = drat)) +
227227
geom_point() +
@@ -231,7 +231,7 @@ test_that("legend.key.justification works as intended", {
231231
scale_colour_discrete(
232232
labels = c("one line", "up\nto\nfour\nlines", "up\nto\nfive\nwhole\nlines")
233233
) +
234-
theme(legend.key.justification = c(1, 0))
234+
theme(legend.key.just = c(1, 0))
235235

236236
expect_doppelganger("legend key justification", p)
237237

tests/testthat/test-guides.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,13 @@ test_that("guides are positioned correctly", {
274274
p2 + theme(legend.position.inside = c(0.5, 0.5))
275275
)
276276
expect_doppelganger("legend inside plot, bottom left",
277-
p2 + theme(legend.justification = c(0,0), legend.position.inside = c(0,0))
277+
p2 + theme(legend.just = c(0,0), legend.position.inside = c(0,0))
278278
)
279279
expect_doppelganger("legend inside plot, top right",
280-
p2 + theme(legend.justification = c(1,1), legend.position.inside = c(1,1))
280+
p2 + theme(legend.just = c(1,1), legend.position.inside = c(1,1))
281281
)
282282
expect_doppelganger("legend inside plot, bottom left of legend at center",
283-
p2 + theme(legend.justification = c(0,0), legend.position.inside = c(0.5,0.5))
283+
p2 + theme(legend.just = c(0,0), legend.position.inside = c(0.5,0.5))
284284
)
285285
expect_doppelganger("legend inside plot, multiple positions",
286286
p2 +
@@ -289,14 +289,14 @@ test_that("guides are positioned correctly", {
289289
position = "inside",
290290
theme = theme(
291291
legend.position.inside = c(0, 1),
292-
legend.justification.inside = c(0, 1)
292+
legend.just.inside = c(0, 1)
293293
)
294294
),
295295
fill = guide_legend(
296296
position = "inside",
297297
theme = theme(
298298
legend.position.inside = c(1, 0),
299-
legend.justification.inside = c(1, 0)
299+
legend.just.inside = c(1, 0)
300300
)
301301
)
302302
)

tests/testthat/test-theme.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,11 +1026,11 @@ test_that("Legends can on all sides of the plot with custom justification", {
10261026
) +
10271027
theme_test() +
10281028
theme(
1029-
legend.justification.top = "left",
1030-
legend.justification.bottom = c(1, 0),
1031-
legend.justification.left = c(0, 1),
1032-
legend.justification.right = "bottom",
1033-
legend.justification.inside = c(0.75, 0.75),
1029+
legend.just.top = "left",
1030+
legend.just.bottom = c(1, 0),
1031+
legend.just.left = c(0, 1),
1032+
legend.just.right = "bottom",
1033+
legend.just.inside = c(0.75, 0.75),
10341034
legend.location = "plot"
10351035
)
10361036

0 commit comments

Comments
 (0)