From 4bc18bb48fcff0497f1cfefae353451ea17b1b28 Mon Sep 17 00:00:00 2001 From: Teun van den Brand <49372158+teunbrand@users.noreply.github.com> Date: Wed, 13 Jan 2021 20:23:17 +0100 Subject: [PATCH 1/6] Multiply linewidths by .pt before handing off to `gpar()` --- R/guide-colorbar.r | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/guide-colorbar.r b/R/guide-colorbar.r index fd352fd789..a3bce53e39 100644 --- a/R/guide-colorbar.r +++ b/R/guide-colorbar.r @@ -322,7 +322,7 @@ guide_gengrob.colorbar <- function(guide, theme) { default.units = "cm", gp = gpar( col = guide$frame.colour, - lwd = guide$frame.linewidth, + lwd = guide$frame.linewidth * .pt, lty = guide$frame.linetype, fill = NA) ) @@ -451,7 +451,7 @@ guide_gengrob.colorbar <- function(guide, theme) { default.units = "cm", gp = gpar( col = guide$ticks.colour, - lwd = guide$ticks.linewidth, + lwd = guide$ticks.linewidth * .pt, lineend = "butt" ) ) From d57de610cb4bd462d9e1ff8fdf1d3841c1d92019 Mon Sep 17 00:00:00 2001 From: Teun van den Brand <49372158+teunbrand@users.noreply.github.com> Date: Wed, 13 Jan 2021 20:24:45 +0100 Subject: [PATCH 2/6] Adjust defaults / test case accordingly --- R/guide-colorbar.r | 4 ++-- tests/testthat/test-guides.R | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/guide-colorbar.r b/R/guide-colorbar.r index a3bce53e39..48c5727074 100644 --- a/R/guide-colorbar.r +++ b/R/guide-colorbar.r @@ -125,13 +125,13 @@ guide_colourbar <- function( # frame frame.colour = NULL, - frame.linewidth = 0.5, + frame.linewidth = 0.5 / .pt, frame.linetype = 1, # ticks ticks = TRUE, ticks.colour = "white", - ticks.linewidth = 0.5, + ticks.linewidth = 0.5 / .pt, draw.ulim= TRUE, draw.llim = TRUE, diff --git a/tests/testthat/test-guides.R b/tests/testthat/test-guides.R index 2680bacf27..18371542bf 100644 --- a/tests/testthat/test-guides.R +++ b/tests/testthat/test-guides.R @@ -460,9 +460,9 @@ test_that("colorbar can be styled", { low = 'white', high = 'red', guide = guide_colorbar( frame.colour = "green", - frame.linewidth = 1.5, + frame.linewidth = 1.5 / .pt, ticks.colour = "black", - ticks.linewidth = 2.5 + ticks.linewidth = 2.5 / .pt ) ) ) From 1cf24aec63dd5bc9199d9d4478d603c37dd2d199 Mon Sep 17 00:00:00 2001 From: Teun van den Brand <49372158+teunbrand@users.noreply.github.com> Date: Sat, 16 Jan 2021 23:17:52 +0100 Subject: [PATCH 3/6] Add NEWS.md bullet --- NEWS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.md b/NEWS.md index 95fdb0541d..70786632b3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -24,6 +24,11 @@ * ggplot2 now requires R >= 3.3 (#4247). +* The `ticks.linewidth` and `frame.linewidth` parameters of `guide_colourbar()` + are now multiplied with `.pt` like elsewhere in ggplot2. It can cause visual + changes when these arguments are not the defaults and these changes can be + restored to their previous behaviour by adding `/ .pt` (@teunbrand #4314). + # ggplot2 3.3.3 This is a small patch release mainly intended to address changes in R and CRAN. It further changes the licensing model of ggplot2 to an MIT license. From 52469523107ab3d920af7c7082794257a4cc5356 Mon Sep 17 00:00:00 2001 From: Teun van den Brand <49372158+teunbrand@users.noreply.github.com> Date: Sat, 16 Jan 2021 23:18:04 +0100 Subject: [PATCH 4/6] Regenerate documents --- man/guide_colourbar.Rd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/man/guide_colourbar.Rd b/man/guide_colourbar.Rd index e2a6252013..00b099ed94 100644 --- a/man/guide_colourbar.Rd +++ b/man/guide_colourbar.Rd @@ -21,11 +21,11 @@ guide_colourbar( nbin = 300, raster = TRUE, frame.colour = NULL, - frame.linewidth = 0.5, + frame.linewidth = 0.5/.pt, frame.linetype = 1, ticks = TRUE, ticks.colour = "white", - ticks.linewidth = 0.5, + ticks.linewidth = 0.5/.pt, draw.ulim = TRUE, draw.llim = TRUE, direction = NULL, @@ -52,11 +52,11 @@ guide_colorbar( nbin = 300, raster = TRUE, frame.colour = NULL, - frame.linewidth = 0.5, + frame.linewidth = 0.5/.pt, frame.linetype = 1, ticks = TRUE, ticks.colour = "white", - ticks.linewidth = 0.5, + ticks.linewidth = 0.5/.pt, draw.ulim = TRUE, draw.llim = TRUE, direction = NULL, From c6b4159204b14dc13b46411bfe6eeb69dc37352a Mon Sep 17 00:00:00 2001 From: Teun van den Brand <49372158+teunbrand@users.noreply.github.com> Date: Wed, 16 Mar 2022 00:24:59 +0100 Subject: [PATCH 5/6] Move news bullet to dev version --- NEWS.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1044414c64..aa1e6f5795 100644 --- a/NEWS.md +++ b/NEWS.md @@ -64,6 +64,10 @@ * Updated documentation for `geom_contour()` to correctly reflect argument precedence between `bins` and `binwidth`. (@eliocamp, #4651) +* The `ticks.linewidth` and `frame.linewidth` parameters of `guide_colourbar()` + are now multiplied with `.pt` like elsewhere in ggplot2. It can cause visual + changes when these arguments are not the defaults and these changes can be + restored to their previous behaviour by adding `/ .pt` (@teunbrand #4314). # ggplot2 3.3.5 This is a very small release focusing on fixing a couple of untenable issues @@ -228,11 +232,6 @@ small selection of feature refinements. * ggplot2 now requires R >= 3.3 (#4247). -* The `ticks.linewidth` and `frame.linewidth` parameters of `guide_colourbar()` - are now multiplied with `.pt` like elsewhere in ggplot2. It can cause visual - changes when these arguments are not the defaults and these changes can be - restored to their previous behaviour by adding `/ .pt` (@teunbrand #4314). - * ggplot2 now uses `rlang::check_installed()` to check if a suggested package is installed, which will offer to install the package before continuing (#4375, @malcolmbarrett) From 466ba00eda718c478739e93ccc5d29ca5d068b29 Mon Sep 17 00:00:00 2001 From: Teun van den Brand <49372158+teunbrand@users.noreply.github.com> Date: Wed, 16 Mar 2022 00:26:23 +0100 Subject: [PATCH 6/6] Reflect units in docs --- R/guide-colorbar.r | 5 +++-- man/guide_colourbar.Rd | 5 +++-- man/guide_coloursteps.Rd | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/R/guide-colorbar.r b/R/guide-colorbar.r index 4c1460715c..b65e316b48 100644 --- a/R/guide-colorbar.r +++ b/R/guide-colorbar.r @@ -21,7 +21,7 @@ #' @param frame.colour A string specifying the colour of the frame #' drawn around the bar. If `NULL` (the default), no frame is drawn. #' @param frame.linewidth A numeric specifying the width of the frame -#' drawn around the bar. +#' drawn around the bar in millimetres. #' @param frame.linetype A numeric specifying the linetype of the frame #' drawn around the bar. #' @param nbin A numeric specifying the number of bins for drawing the @@ -33,7 +33,8 @@ #' @param ticks A logical specifying if tick marks on the colourbar should be #' visible. #' @param ticks.colour A string specifying the colour of the tick marks. -#' @param ticks.linewidth A numeric specifying the width of the tick marks. +#' @param ticks.linewidth A numeric specifying the width of the tick marks in +#' millimetres. #' @param draw.ulim A logical specifying if the upper limit tick marks should #' be visible. #' @param draw.llim A logical specifying if the lower limit tick marks should diff --git a/man/guide_colourbar.Rd b/man/guide_colourbar.Rd index 00b099ed94..b00f6956c5 100644 --- a/man/guide_colourbar.Rd +++ b/man/guide_colourbar.Rd @@ -124,7 +124,7 @@ raster image.} drawn around the bar. If \code{NULL} (the default), no frame is drawn.} \item{frame.linewidth}{A numeric specifying the width of the frame -drawn around the bar.} +drawn around the bar in millimetres.} \item{frame.linetype}{A numeric specifying the linetype of the frame drawn around the bar.} @@ -134,7 +134,8 @@ visible.} \item{ticks.colour}{A string specifying the colour of the tick marks.} -\item{ticks.linewidth}{A numeric specifying the width of the tick marks.} +\item{ticks.linewidth}{A numeric specifying the width of the tick marks in +millimetres.} \item{draw.ulim}{A logical specifying if the upper limit tick marks should be visible.} diff --git a/man/guide_coloursteps.Rd b/man/guide_coloursteps.Rd index 2656d48d9d..98ed9c382c 100644 --- a/man/guide_coloursteps.Rd +++ b/man/guide_coloursteps.Rd @@ -31,11 +31,12 @@ the height of the colourbar. Default value is \code{legend.key.height} or \item{\code{frame.colour}}{A string specifying the colour of the frame drawn around the bar. If \code{NULL} (the default), no frame is drawn.} \item{\code{frame.linewidth}}{A numeric specifying the width of the frame -drawn around the bar.} +drawn around the bar in millimetres.} \item{\code{frame.linetype}}{A numeric specifying the linetype of the frame drawn around the bar.} \item{\code{ticks.colour}}{A string specifying the colour of the tick marks.} - \item{\code{ticks.linewidth}}{A numeric specifying the width of the tick marks.} + \item{\code{ticks.linewidth}}{A numeric specifying the width of the tick marks in +millimetres.} \item{\code{draw.ulim}}{A logical specifying if the upper limit tick marks should be visible.} \item{\code{draw.llim}}{A logical specifying if the lower limit tick marks should