Skip to content

The colorbar guide (guide_colourbar) incorrectly uses a vertical unit in a horizontal setting #2397

Closed
@clauswilke

Description

@clauswilke

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)

screen shot 2018-01-11 at 11 31 08 am

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorthemes 💃wipwork in progress

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions