Skip to content

The colorbar guide (guide_colourbar) converts units into cm and then uses them as mmย #2398

@clauswilke

Description

@clauswilke

The colorbar guide (guide_colourbar) converts units into cm and then uses them as mm. Reproducible example:

library(ggplot2)
p1 <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Petal.Width)) + geom_point() +
  scale_color_distiller(name = "gap width = 1cm") +
  theme(legend.spacing.x = grid::unit(1, "cm"),
        legend.position = "top")
p2 <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Petal.Width)) + geom_point() +
  scale_color_distiller(name = "gap width = 10cm") +
  theme(legend.spacing.x = grid::unit(10, "cm"),
        legend.position = "top")
p3 <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Petal.Width)) + geom_point() +
  scale_color_distiller(name = "gap width = 50cm") +
  theme(legend.spacing.x = grid::unit(50, "cm"),
        legend.position = "top")

cowplot::plot_grid(p1, p2, p3, nrow = 1)

screen shot 2018-01-11 at 11 47 13 am

The problem exists for both legend.spacing.x and legend.spacing.y but cannot be shown for legend.spacing.y because of issue #2260, which has not yet been fixed for guide_colourbar.

The relevant lines in the code are here (convert legend.spacing.x and legend.spacing.y into cm) and here (use all widths and heights as mm values.)

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