'Why and when "Using size for a discrete variable is not advised"?

I made a scatterplot with ggplot2 and I mapped a binary variable to point size. The result was satisfactory but I got the warning "Using size for a discrete variable is not advised".

I understand that using size to map a non ordinal categorical variable with several levels may be less clear than using point shape or different colors. However, I wonder whether that warning is intended to warn us about anything more serious.

Is there a more advisable way to change point size according to a binary or categorical variable than using aes(size=...)?

Is the warning "Using size for a discrete variable is not advised" just a design tip?

If my result looks good, should I worry about that warning next time I want the same kind of graphic on similar data?



Solution 1:[1]

As the comments and you have mentioned, if you use size for categorical variables, then you mislead the reader.

If you have numbers and have this error, convert them with as.numeric(), as they may have been stored as factors or character values. That will sort out the legend too.

Solution 2:[2]

The reason for this Warning is that size is an ordered aesthetic, and you are mapping an unordered variable to an ordered aesthetic (size) which is not a good idea. Try using ordered = T in your as.factor() or factor() function while you are building your variable, and that fixes this issue. You can also use ordered() function instead of factor().

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter
Solution 2 ah bon