From 442c4574b72e749f4c2711dc7d9c9447153ad97c Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 29 Nov 2023 09:19:36 +0100 Subject: [PATCH 1/2] enable x-margins --- R/plot-build.R | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/R/plot-build.R b/R/plot-build.R index 10ffaa9ae5..e5b60ff15a 100644 --- a/R/plot-build.R +++ b/R/plot-build.R @@ -265,15 +265,24 @@ ggplot_gtable.ggplot_built <- function(data) { } # Title - title <- element_render(theme, "plot.title", plot$labels$title, margin_y = TRUE) + title <- element_render( + theme, "plot.title", plot$labels$title, + margin_y = TRUE, margin_x = TRUE + ) title_height <- grobHeight(title) # Subtitle - subtitle <- element_render(theme, "plot.subtitle", plot$labels$subtitle, margin_y = TRUE) + subtitle <- element_render( + theme, "plot.subtitle", plot$labels$subtitle, + margin_y = TRUE, margin_x = TRUE + ) subtitle_height <- grobHeight(subtitle) # whole plot annotation - caption <- element_render(theme, "plot.caption", plot$labels$caption, margin_y = TRUE) + caption <- element_render( + theme, "plot.caption", plot$labels$caption, + margin_y = TRUE, margin_x = TRUE + ) caption_height <- grobHeight(caption) # positioning of title and subtitle is governed by plot.title.position From 188fc3bbee21ff038dc7b3aca97f84cc510e4282 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 29 Nov 2023 09:27:52 +0100 Subject: [PATCH 2/2] add news bullet --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index 4596436f9a..1cd599e42e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # ggplot2 (development version) +* The plot's title, subtitle and caption now obey horizontal text margins + (#5533). + * Lines where `linewidth = NA` are now dropped in `geom_sf()` (#5204). * New `guide_axis_logticks()` can be used to draw logarithmic tick marks as