Skip to content

scale_manual warning "no shared levels" could be improved #6429

Open
@tdhock

Description

@tdhock

Related to #5669 which discusses this warning.

I tried adding aes(size) an a geom which already had size defined as a parameter, and I got the following warning:

library(ggplot2)
ggplot()+
  scale_size_manual(values=c(a=2,b=4))+
  geom_point(aes(
    x,x,size=x),
    size=3,
    data=data.frame(x=c('a','b')))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's size values.

Created on 2025-04-15 with reprex v2.1.1

It took me some time before I realized that the solution was to remove size=3.

I would suggest improving the warning to say something like "size has been specified in aes and as a parameter in geom_point; please remove one or the other" which would be much more helpful than the current warning.

Thanks for maintaining ggplot2!

Metadata

Metadata

Assignees

No one assigned

    Labels

    messagesrequests for improvements to error, warning, or feedback messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions