You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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!
The text was updated successfully, but these errors were encountered:
Thanks for the suggestion! This is a warning thrown by the scale. Scales are ignorant about layers, so they don't know what mappings or fixed aesthetics layers have set. For this reason, the exact warning you point out cannot (within reason) be updated to include the specifics about the layer.
Alternatively, we could have layers warn when simultaneously using a fixed parameter and re-use the aesthetic in the mapping. However, I don't currently know how common it is for people's code to declare both but the code also works as intended.
A second option is to have the scale warning spell out the two levels, so it is easier to spot what the mismatch is.
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:
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!
The text was updated successfully, but these errors were encountered: