diff --git a/NEWS.md b/NEWS.md
index ac58e9c933..a6daad8503 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -82,6 +82,8 @@
* Fix a bug when `show.legend` is a named logical vector (#3461, @yutannihilation).
+* Increase the default `nbin` of `guide_colourbar()` to place the ticks more precisely (#3508, @yutannihilation).
+
# ggplot2 3.2.1
This is a patch release fixing a few regressions introduced in 3.2.0 as well as
diff --git a/R/guide-colorbar.r b/R/guide-colorbar.r
index 26a959ad3f..95e62297e4 100644
--- a/R/guide-colorbar.r
+++ b/R/guide-colorbar.r
@@ -116,7 +116,7 @@ guide_colourbar <- function(
# bar
barwidth = NULL,
barheight = NULL,
- nbin = 20,
+ nbin = 300,
raster = TRUE,
# frame
diff --git a/man/guide_colourbar.Rd b/man/guide_colourbar.Rd
index c7eebdfa4d..c256aa30f6 100644
--- a/man/guide_colourbar.Rd
+++ b/man/guide_colourbar.Rd
@@ -9,7 +9,7 @@ guide_colourbar(title = waiver(), title.position = NULL,
title.theme = NULL, title.hjust = NULL, title.vjust = NULL,
label = TRUE, label.position = NULL, label.theme = NULL,
label.hjust = NULL, label.vjust = NULL, barwidth = NULL,
- barheight = NULL, nbin = 20, raster = TRUE, frame.colour = NULL,
+ barheight = NULL, nbin = 300, raster = TRUE, frame.colour = NULL,
frame.linewidth = 0.5, frame.linetype = 1, ticks = TRUE,
ticks.colour = "white", ticks.linewidth = 0.5, draw.ulim = TRUE,
draw.llim = TRUE, direction = NULL, default.unit = "line",
@@ -20,7 +20,7 @@ guide_colorbar(title = waiver(), title.position = NULL,
title.theme = NULL, title.hjust = NULL, title.vjust = NULL,
label = TRUE, label.position = NULL, label.theme = NULL,
label.hjust = NULL, label.vjust = NULL, barwidth = NULL,
- barheight = NULL, nbin = 20, raster = TRUE, frame.colour = NULL,
+ barheight = NULL, nbin = 300, raster = TRUE, frame.colour = NULL,
frame.linewidth = 0.5, frame.linetype = 1, ticks = TRUE,
ticks.colour = "white", ticks.linewidth = 0.5, draw.ulim = TRUE,
draw.llim = TRUE, direction = NULL, default.unit = "line",
diff --git a/tests/figs/geom-raster/1-x-3-just-0-0.svg b/tests/figs/geom-raster/1-x-3-just-0-0.svg
index d77a4cdbbe..114524f450 100644
--- a/tests/figs/geom-raster/1-x-3-just-0-0.svg
+++ b/tests/figs/geom-raster/1-x-3-just-0-0.svg
@@ -50,22 +50,22 @@
x
y
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
z
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
1 x 3, just = (0, 0)
diff --git a/tests/figs/geom-raster/1-x-3-set-limits.svg b/tests/figs/geom-raster/1-x-3-set-limits.svg
index 26e3bcce25..a1dd5fdbc9 100644
--- a/tests/figs/geom-raster/1-x-3-set-limits.svg
+++ b/tests/figs/geom-raster/1-x-3-set-limits.svg
@@ -52,22 +52,22 @@
x
y
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
z
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
1 x 3, set limits
diff --git a/tests/figs/geom-raster/1-x-3.svg b/tests/figs/geom-raster/1-x-3.svg
index 3525628004..5b4fc66ca2 100644
--- a/tests/figs/geom-raster/1-x-3.svg
+++ b/tests/figs/geom-raster/1-x-3.svg
@@ -48,22 +48,22 @@
x
y
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
z
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
1 x 3
diff --git a/tests/figs/geom-raster/3-x-1-just-0-0.svg b/tests/figs/geom-raster/3-x-1-just-0-0.svg
index fbde706d0e..83e93def0b 100644
--- a/tests/figs/geom-raster/3-x-1-just-0-0.svg
+++ b/tests/figs/geom-raster/3-x-1-just-0-0.svg
@@ -50,22 +50,22 @@
x
y
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
z
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
3 x 1, just = (0, 0)
diff --git a/tests/figs/geom-raster/3-x-1-set-limits.svg b/tests/figs/geom-raster/3-x-1-set-limits.svg
index cfd6ac0627..90fafa19c1 100644
--- a/tests/figs/geom-raster/3-x-1-set-limits.svg
+++ b/tests/figs/geom-raster/3-x-1-set-limits.svg
@@ -52,22 +52,22 @@
x
y
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
z
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
3 x 1, set limits
diff --git a/tests/figs/geom-raster/3-x-1.svg b/tests/figs/geom-raster/3-x-1.svg
index e7de40e37f..089e142e72 100644
--- a/tests/figs/geom-raster/3-x-1.svg
+++ b/tests/figs/geom-raster/3-x-1.svg
@@ -48,22 +48,22 @@
x
y
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
z
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
3 x 1
diff --git a/tests/figs/geom-raster/3-x-2-just-0-0.svg b/tests/figs/geom-raster/3-x-2-just-0-0.svg
index e1b3cc5f40..66d9a85fdc 100644
--- a/tests/figs/geom-raster/3-x-2-just-0-0.svg
+++ b/tests/figs/geom-raster/3-x-2-just-0-0.svg
@@ -53,25 +53,25 @@
x
y
-
-1
-2
-3
-4
-5
-6
+
+1
+2
+3
+4
+5
+6
z
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
3 x 2, just = (0, 0)
diff --git a/tests/figs/geom-raster/3-x-2-set-limits.svg b/tests/figs/geom-raster/3-x-2-set-limits.svg
index e8c4ff87a6..db9074cf90 100644
--- a/tests/figs/geom-raster/3-x-2-set-limits.svg
+++ b/tests/figs/geom-raster/3-x-2-set-limits.svg
@@ -55,25 +55,25 @@
x
y
-
-1
-2
-3
-4
-5
-6
+
+1
+2
+3
+4
+5
+6
z
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
3 x 2, set limits
diff --git a/tests/figs/geom-raster/3-x-2.svg b/tests/figs/geom-raster/3-x-2.svg
index 34087850a2..64e8a6ff9b 100644
--- a/tests/figs/geom-raster/3-x-2.svg
+++ b/tests/figs/geom-raster/3-x-2.svg
@@ -51,25 +51,25 @@
x
y
-
-1
-2
-3
-4
-5
-6
+
+1
+2
+3
+4
+5
+6
z
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
3 x 2
diff --git a/tests/figs/guides/guide-title-and-text-positioning-and-alignment-via-themes.svg b/tests/figs/guides/guide-title-and-text-positioning-and-alignment-via-themes.svg
index 68fd09d954..dae2e7c107 100644
--- a/tests/figs/guides/guide-title-and-text-positioning-and-alignment-via-themes.svg
+++ b/tests/figs/guides/guide-title-and-text-positioning-and-alignment-via-themes.svg
@@ -51,20 +51,20 @@
x
x
-
-25
-50
-75
-100
+
+25
+50
+75
+100
x
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
x
diff --git a/tests/figs/guides/horizontal-gap-of-1cm-between-guide-and-guide-text.svg b/tests/figs/guides/horizontal-gap-of-1cm-between-guide-and-guide-text.svg
index 4c445824c6..fadcc45eb1 100644
--- a/tests/figs/guides/horizontal-gap-of-1cm-between-guide-and-guide-text.svg
+++ b/tests/figs/guides/horizontal-gap-of-1cm-between-guide-and-guide-text.svg
@@ -51,23 +51,23 @@
x
y
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
y
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
factor(x)
diff --git a/tests/figs/guides/legend-inside-plot-bottom-left-of-legend-at-center.svg b/tests/figs/guides/legend-inside-plot-bottom-left-of-legend-at-center.svg
index 3ac5878494..b9cace887b 100644
--- a/tests/figs/guides/legend-inside-plot-bottom-left-of-legend-at-center.svg
+++ b/tests/figs/guides/legend-inside-plot-bottom-left-of-legend-at-center.svg
@@ -58,22 +58,22 @@
B
C
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
1:3
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
legend inside plot, bottom left of legend at center
diff --git a/tests/figs/guides/legend-inside-plot-bottom-left.svg b/tests/figs/guides/legend-inside-plot-bottom-left.svg
index 5a975fe381..0e1ba6ee26 100644
--- a/tests/figs/guides/legend-inside-plot-bottom-left.svg
+++ b/tests/figs/guides/legend-inside-plot-bottom-left.svg
@@ -58,22 +58,22 @@
B
C
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
1:3
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
legend inside plot, bottom left
diff --git a/tests/figs/guides/legend-inside-plot-centered.svg b/tests/figs/guides/legend-inside-plot-centered.svg
index 158ab3abe2..cf71a88ffc 100644
--- a/tests/figs/guides/legend-inside-plot-centered.svg
+++ b/tests/figs/guides/legend-inside-plot-centered.svg
@@ -58,22 +58,22 @@
B
C
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
1:3
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
legend inside plot, centered
diff --git a/tests/figs/guides/legend-inside-plot-top-right.svg b/tests/figs/guides/legend-inside-plot-top-right.svg
index 0fe7c38b9c..b0feec5e12 100644
--- a/tests/figs/guides/legend-inside-plot-top-right.svg
+++ b/tests/figs/guides/legend-inside-plot-top-right.svg
@@ -58,22 +58,22 @@
B
C
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
1:3
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
legend inside plot, top right
diff --git a/tests/figs/guides/multi-line-guide-title-works.svg b/tests/figs/guides/multi-line-guide-title-works.svg
index d2af399b45..c7ee1f67ab 100644
--- a/tests/figs/guides/multi-line-guide-title-works.svg
+++ b/tests/figs/guides/multi-line-guide-title-works.svg
@@ -51,25 +51,25 @@
x
y
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
the
continuous
colorscale
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
the
discrete
diff --git a/tests/figs/guides/one-combined-colorbar-for-colour-and-fill-aesthetics.svg b/tests/figs/guides/one-combined-colorbar-for-colour-and-fill-aesthetics.svg
index 0ef27cad25..e8e61da7ec 100644
--- a/tests/figs/guides/one-combined-colorbar-for-colour-and-fill-aesthetics.svg
+++ b/tests/figs/guides/one-combined-colorbar-for-colour-and-fill-aesthetics.svg
@@ -51,28 +51,28 @@
x
y
-
-1
-2
-3
+
+1
+2
+3
4
-5
-6
-7
+5
+6
+7
value
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
one combined colorbar for colour and fill aesthetics
diff --git a/tests/figs/guides/padding-in-legend-box.svg b/tests/figs/guides/padding-in-legend-box.svg
index 8f1ff61213..4d486e6126 100644
--- a/tests/figs/guides/padding-in-legend-box.svg
+++ b/tests/figs/guides/padding-in-legend-box.svg
@@ -58,22 +58,22 @@
B
C
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
1:3
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
padding in legend box
diff --git a/tests/figs/guides/rotated-guide-titles-and-labels.svg b/tests/figs/guides/rotated-guide-titles-and-labels.svg
index 247c5938d8..1bfcfd86e9 100644
--- a/tests/figs/guides/rotated-guide-titles-and-labels.svg
+++ b/tests/figs/guides/rotated-guide-titles-and-labels.svg
@@ -62,22 +62,22 @@
long 10
long 15
-
-5.0
-7.5
+
+5.0
+7.5
10.0
-12.5
-15.0
+12.5
+15.0
value
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
rotated guide titles and labels
diff --git a/tests/figs/guides/vertical-gap-of-1cm-between-guide-title-and-guide.svg b/tests/figs/guides/vertical-gap-of-1cm-between-guide-title-and-guide.svg
index 16b5919189..dd5f97b58e 100644
--- a/tests/figs/guides/vertical-gap-of-1cm-between-guide-title-and-guide.svg
+++ b/tests/figs/guides/vertical-gap-of-1cm-between-guide-title-and-guide.svg
@@ -51,23 +51,23 @@
x
y
-
-1.0
-1.5
+
+1.0
+1.5
2.0
-2.5
-3.0
+2.5
+3.0
y
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
factor(x)
diff --git a/tests/figs/guides/white-to-red-gradient-colorbar-thick-black-tick-marks-green-frame.svg b/tests/figs/guides/white-to-red-gradient-colorbar-thick-black-tick-marks-green-frame.svg
index d2a6246c1c..b7e852bba4 100644
--- a/tests/figs/guides/white-to-red-gradient-colorbar-thick-black-tick-marks-green-frame.svg
+++ b/tests/figs/guides/white-to-red-gradient-colorbar-thick-black-tick-marks-green-frame.svg
@@ -51,23 +51,23 @@
x
x
-
+
-0.0
-0.5
+0.0
+0.5
1.0
-1.5
-2.0
+1.5
+2.0
x
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
white-to-red gradient colorbar, thick black tick marks, green frame
diff --git a/tests/figs/guides/white-to-red-gradient-colorbar-white-tick-marks-no-frame.svg b/tests/figs/guides/white-to-red-gradient-colorbar-white-tick-marks-no-frame.svg
index d6bcdaf6fe..cb60f013aa 100644
--- a/tests/figs/guides/white-to-red-gradient-colorbar-white-tick-marks-no-frame.svg
+++ b/tests/figs/guides/white-to-red-gradient-colorbar-white-tick-marks-no-frame.svg
@@ -51,22 +51,22 @@
x
x
-
-0.0
-0.5
+
+0.0
+0.5
1.0
-1.5
-2.0
+1.5
+2.0
x
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
white-to-red gradient colorbar, white tick marks, no frame