Skip to content

Commit 49a955f

Browse files
committed
use margin_auto() where appropriate
1 parent aa07be6 commit 49a955f

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

R/geom-rug.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#' p +
4646
#' geom_rug(outside = TRUE, sides = "tr") +
4747
#' coord_cartesian(clip = "off") +
48-
#' theme(plot.margin = margin(1, 1, 1, 1, "cm"))
48+
#' theme(plot.margin = margin_auto(1, unit = "cm"))
4949
#'
5050
#' # increase the line length and
5151
#' # expand axis to avoid overplotting

R/legend-draw.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ draw_key_text <- function(data, params, size) {
277277
fontface = data$fontface %||% 1,
278278
fontsize = (data$size %||% 3.88) * .pt
279279
),
280-
margin = margin(0.1, 0.1, 0.1, 0.1, unit = "lines"),
280+
margin = margin_auto(0.1, unit = "lines"),
281281
margin_x = TRUE, margin_y = TRUE
282282
)
283283
attr(grob, "width") <- convertWidth(grobWidth(grob), "cm", valueOnly = TRUE)

R/theme-defaults.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ theme_grey <- function(base_size = 11, base_family = "",
143143
title = element_text(family = header_family),
144144

145145
spacing = unit(half_line, "pt"),
146-
margins = margin(half_line, half_line, half_line, half_line),
146+
margins = margin_auto(half_line),
147147

148148
geom = element_geom(
149149
ink = ink, paper = paper, accent = "#3366FF",
@@ -226,7 +226,7 @@ theme_grey <- function(base_size = 11, base_family = "",
226226
strip.text = element_text(
227227
colour = col_mix(ink, paper, 0.105),
228228
size = rel(0.8),
229-
margin = margin(0.8 * half_line, 0.8 * half_line, 0.8 * half_line, 0.8 * half_line)
229+
margin = margin_auto(0.8 * half_line)
230230
),
231231
strip.text.x = NULL,
232232
strip.text.y = element_text(angle = -90),
@@ -341,7 +341,7 @@ theme_linedraw <- function(base_size = 11, base_family = "",
341341
strip.text = element_text(
342342
colour = paper,
343343
size = rel(0.8),
344-
margin = margin(0.8 * half_line, 0.8 * half_line, 0.8 * half_line, 0.8 * half_line)
344+
margin = margin_auto(0.8 * half_line)
345345
),
346346

347347
complete = TRUE
@@ -384,7 +384,7 @@ theme_light <- function(base_size = 11, base_family = "",
384384
strip.text = element_text(
385385
colour = paper,
386386
size = rel(0.8),
387-
margin = margin(0.8 * half_line, 0.8 * half_line, 0.8 * half_line, 0.8 * half_line)
387+
margin = margin_auto(0.8 * half_line)
388388
),
389389

390390
complete = TRUE
@@ -427,7 +427,7 @@ theme_dark <- function(base_size = 11, base_family = "",
427427
strip.text = element_text(
428428
colour = col_mix(ink, paper, 0.9),
429429
size = rel(0.8),
430-
margin = margin(0.8 * half_line, 0.8 * half_line, 0.8 * half_line, 0.8 * half_line)
430+
margin = margin_auto(0.8 * half_line)
431431
),
432432

433433
complete = TRUE
@@ -518,7 +518,7 @@ theme_void <- function(base_size = 11, base_family = "",
518518
),
519519
title = element_text(family = header_family),
520520
spacing = unit(half_line, "pt"),
521-
margins = margin(half_line, half_line, half_line, half_line),
521+
margins = margin_auto(half_line),
522522
axis.text = element_blank(),
523523
axis.title = element_blank(),
524524
axis.ticks.length = rel(0),
@@ -602,7 +602,7 @@ theme_test <- function(base_size = 11, base_family = "",
602602
),
603603
title = element_text(family = header_family),
604604
spacing = unit(half_line, "pt"),
605-
margins = margin(half_line, half_line, half_line, half_line),
605+
margins = margin_auto(half_line),
606606
geom = element_geom(
607607
ink = ink, paper = paper, accent = "#3366FF",
608608
linewidth = base_line_size, borderwidth = base_line_size,
@@ -651,7 +651,7 @@ theme_test <- function(base_size = 11, base_family = "",
651651
legend.spacing = rel(2),
652652
legend.spacing.x = NULL,
653653
legend.spacing.y = NULL,
654-
legend.margin = margin(0, 0, 0, 0, "cm"),
654+
legend.margin = margin_auto(0, unit = "cm"),
655655
legend.key = NULL,
656656
legend.key.size = unit(1.2, "lines"),
657657
legend.key.height = NULL,
@@ -666,7 +666,7 @@ theme_test <- function(base_size = 11, base_family = "",
666666
legend.direction = NULL,
667667
legend.justification = "center",
668668
legend.box = NULL,
669-
legend.box.margin = margin(0, 0, 0, 0, "cm"),
669+
legend.box.margin = margin_auto(0, unit = "cm"),
670670
legend.box.background = element_blank(),
671671
legend.box.spacing = rel(2),
672672

@@ -687,7 +687,7 @@ theme_test <- function(base_size = 11, base_family = "",
687687
strip.text = element_text(
688688
colour = col_mix(ink, paper, 0.105),
689689
size = rel(0.8),
690-
margin = margin(0.8 * half_line, 0.8 * half_line, 0.8 * half_line, 0.8 * half_line)
690+
margin = margin_auto(0.8 * half_line)
691691
),
692692
strip.text.x = NULL,
693693
strip.text.y = element_text(angle = -90),

R/theme-elements.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#'
4444
#' plot + theme(
4545
#' panel.background = element_rect(fill = "white"),
46-
#' plot.margin = margin(2, 2, 2, 2, "cm"),
46+
#' plot.margin = margin_auto(2, unit = "cm"),
4747
#' plot.background = element_rect(
4848
#' fill = "grey90",
4949
#' colour = "black",

R/theme.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,14 @@
281281
#' legend.position.inside = c(.95, .95),
282282
#' legend.justification = c("right", "top"),
283283
#' legend.box.just = "right",
284-
#' legend.margin = margin(6, 6, 6, 6)
284+
#' legend.margin = margin_auto(6)
285285
#' )
286286
#'
287287
#' # The legend.box properties work similarly for the space around
288288
#' # all the legends
289289
#' p2 + theme(
290290
#' legend.box.background = element_rect(),
291-
#' legend.box.margin = margin(6, 6, 6, 6)
291+
#' legend.box.margin = margin_auto(6)
292292
#' )
293293
#'
294294
#' # You can also control the display of the keys

man/element.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_rug.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/theme.Rd

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

0 commit comments

Comments
 (0)