Closed
Description
The colorbar guide (guide_colourbar
) incorrectly uses a vertical unit in a horizontal setting. The simplest way to see this issue is the following experiment: Increase the height of the colorbar title and observe that the guide ticks are moving to the right at the same time.
library(ggplot2)
p1 <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Petal.Width)) + geom_point() +
scale_color_distiller(name = "Petal Width")
p2 <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Petal.Width)) + geom_point() +
scale_color_distiller(name = "Petal\nWidth")
p3 <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Petal.Width)) + geom_point() +
scale_color_distiller(name = "Petal\n\nWidth")
cowplot::plot_grid(p1, p2, p3, nrow = 1)
The problem is caused by this line and/or this line. The variable vgap
is being used as a width. The correct variable here would be hgap
. See e.g. this line, which is correct.