patchwork icon indicating copy to clipboard operation
patchwork copied to clipboard

guides = "collect" can't process 3 digit hex codes in guide shape outlines

Open occamkg opened this issue 11 months ago • 0 comments

For geoms that have color and fill, if the color is set using a 3 digit hex code, drawing the guide with plot_layout(guides = "collect") throws an error.

Here is an example to reproduce the error:

ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
    geom_boxplot(color = "#000") +
    plot_layout(guides = "collect")

>> Error: Malformed colour string `#000`. Must contain either 6 or 8 hex values

The geoms that I have found to throw this error are: geom_bar(), geom_boxplot(), and geom_violin()

It seems to work fine if fill is defined with 3 digit hex codes or if the geom doesn't have a fill (I tried geom_point() and geom_line())

Interestingly geom_point() works even when shape > 20

occamkg avatar Apr 18 '25 18:04 occamkg