Skip to content

Multiply colourbar linewidth parameters with *.pt (#4314) #4318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 25, 2022
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 7 additions & 6 deletions R/guide-colorbar.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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)
)
Expand Down Expand Up @@ -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"
)
)
Expand Down
13 changes: 7 additions & 6 deletions man/guide_colourbar.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/guide_coloursteps.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/testthat/test-guides.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
)
Expand Down