Skip to content

Points fill in legendΒ #4049

@DrrDom

Description

@DrrDom

I noticed that if I use fill with geom_point I have to manually set the shape of the legend point to make the fill color visible

library(ggplot2)

set.seed(42)
d <- data.frame(x = rnorm(12), y = rnorm(12), 
                shape = rep(LETTERS[1:4], each = 3), 
                fill = rep(letters[1:3], 4))

ggplot(d, aes(x = x, y = y, shape = shape, fill = fill)) +
  geom_point(size = 3) +
  scale_shape_manual(values = 21:25) +
  theme(legend.box = "horizontal")

0

ggplot(d, aes(x = x, y = y, shape = shape, fill = fill)) +
  geom_point(size = 3) +
  scale_shape_manual(values = 21:25) +
  guides(fill = guide_legend(override.aes=list(shape=21))) +
  theme(legend.box = "horizontal")

1

It seems to be reasonable to change the default behavior in such cases, because it is not obvious and requires search for a solution over the internet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorguides πŸ“

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions