diff --git a/NEWS.md b/NEWS.md index 2369989eb2..2076f813df 100644 --- a/NEWS.md +++ b/NEWS.md @@ -67,6 +67,11 @@ * 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). + * Dots in `geom_dotplot()` are now correctly aligned to the baseline when `stackratio != 1` and `stackdir != "up"` (@mjskay, #4614) diff --git a/R/guide-colorbar.r b/R/guide-colorbar.r index 5c933fa5f0..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 @@ -125,13 +126,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, @@ -322,7 +323,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 +452,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" ) ) diff --git a/man/guide_colourbar.Rd b/man/guide_colourbar.Rd index e2a6252013..b00f6956c5 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, @@ -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 diff --git a/tests/testthat/test-guides.R b/tests/testthat/test-guides.R index c2735c2e89..25960009cd 100644 --- a/tests/testthat/test-guides.R +++ b/tests/testthat/test-guides.R @@ -482,9 +482,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 ) ) )