Skip to content

Commit 2a13934

Browse files
authored
Multiply colourbar linewidth parameters with *.pt (tidyverse#4314) (tidyverse#4318)
1 parent 15b14d3 commit 2a13934

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

NEWS.md

+5
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@
8989
* Updated documentation for `geom_contour()` to correctly reflect argument
9090
precedence between `bins` and `binwidth`. (@eliocamp, #4651)
9191

92+
* The `ticks.linewidth` and `frame.linewidth` parameters of `guide_colourbar()`
93+
are now multiplied with `.pt` like elsewhere in ggplot2. It can cause visual
94+
changes when these arguments are not the defaults and these changes can be
95+
restored to their previous behaviour by adding `/ .pt` (@teunbrand #4314).
96+
9297
* Dots in `geom_dotplot()` are now correctly aligned to the baseline when
9398
`stackratio != 1` and `stackdir != "up"` (@mjskay, #4614)
9499

R/guide-colorbar.r

+7-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#' @param frame.colour A string specifying the colour of the frame
2222
#' drawn around the bar. If `NULL` (the default), no frame is drawn.
2323
#' @param frame.linewidth A numeric specifying the width of the frame
24-
#' drawn around the bar.
24+
#' drawn around the bar in millimetres.
2525
#' @param frame.linetype A numeric specifying the linetype of the frame
2626
#' drawn around the bar.
2727
#' @param nbin A numeric specifying the number of bins for drawing the
@@ -33,7 +33,8 @@
3333
#' @param ticks A logical specifying if tick marks on the colourbar should be
3434
#' visible.
3535
#' @param ticks.colour A string specifying the colour of the tick marks.
36-
#' @param ticks.linewidth A numeric specifying the width of the tick marks.
36+
#' @param ticks.linewidth A numeric specifying the width of the tick marks in
37+
#' millimetres.
3738
#' @param draw.ulim A logical specifying if the upper limit tick marks should
3839
#' be visible.
3940
#' @param draw.llim A logical specifying if the lower limit tick marks should
@@ -125,13 +126,13 @@ guide_colourbar <- function(
125126

126127
# frame
127128
frame.colour = NULL,
128-
frame.linewidth = 0.5,
129+
frame.linewidth = 0.5 / .pt,
129130
frame.linetype = 1,
130131

131132
# ticks
132133
ticks = TRUE,
133134
ticks.colour = "white",
134-
ticks.linewidth = 0.5,
135+
ticks.linewidth = 0.5 / .pt,
135136
draw.ulim= TRUE,
136137
draw.llim = TRUE,
137138

@@ -325,7 +326,7 @@ guide_gengrob.colorbar <- function(guide, theme) {
325326
default.units = "cm",
326327
gp = gpar(
327328
col = guide$frame.colour,
328-
lwd = guide$frame.linewidth,
329+
lwd = guide$frame.linewidth * .pt,
329330
lty = guide$frame.linetype,
330331
fill = NA)
331332
)
@@ -454,7 +455,7 @@ guide_gengrob.colorbar <- function(guide, theme) {
454455
default.units = "cm",
455456
gp = gpar(
456457
col = guide$ticks.colour,
457-
lwd = guide$ticks.linewidth,
458+
lwd = guide$ticks.linewidth * .pt,
458459
lineend = "butt"
459460
)
460461
)

man/guide_colourbar.Rd

+7-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/guide_coloursteps.Rd

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-guides.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,9 @@ test_that("colorbar can be styled", {
529529
low = 'white', high = 'red',
530530
guide = guide_colorbar(
531531
frame.colour = "green",
532-
frame.linewidth = 1.5,
532+
frame.linewidth = 1.5 / .pt,
533533
ticks.colour = "black",
534-
ticks.linewidth = 2.5
534+
ticks.linewidth = 2.5 / .pt
535535
)
536536
)
537537
)

0 commit comments

Comments
 (0)