Skip to content

Omit legend using show.legend = FALSE does not work when aesthetic is continuous #1568

@Henrik-P

Description

@Henrik-P

show.legend = FALSE works as expected when the fill variable is discrete. However, when the aesthetic is mapped to a continuous variable, show.legend = FALSE does not drop the legend.

df <- data.frame(x = 1:3, y = 1)

Discrete fill or color aes:

ggplot(df, aes(x = x, y = y, color = factor(x))) +
  geom_point(size = 20, shape = 21, show.legend = FALSE)

ggplot(df, aes(x = x, y = y, fill = factor(x))) +
  geom_point(size = 20, shape = 21, show.legend = FALSE)

Continuous fill or color aes:

ggplot(df, aes(x = x, y = y, color = x)) +
  geom_point(size = 20, shape = 21, show.legend = FALSE)

ggplot(df, aes(x = x, y = y, fill = x)) +
  geom_point(size = 20, shape = 21, show.legend = FALSE)

ggplot2_2.1.0

Metadata

Metadata

Assignees

Labels

bugan unexpected problem or unintended behavior

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions