Why and when "Using size for a discrete variable is not advised"?
Asked Answered
I

2

8

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?

Interact answered 7/5, 2018 at 10:5 Comment(4)
I view it as a design tip to be broken when necessaryHeurlin
I think you've already mentioned it. Using size to map a non-ordinal categorical variable may suggest an ordinal relationship to the viewer, when none was intended. I find that's quite serious as it could result in miscommunication, but your mileage may vary.Hermes
I think that if you truly want to map categories to size, you should convert the categories to numbers and then do the mapping. That avoids the warning and ensures that the mapping happens exactly the way you want it to.Creech
I feel like this warning is paternalistic and preachey. It has no place in a code warning, it is a style recommendation. Like all style recommendations there are times where it's valid to break it, and then I don't appreciate being warned at.Faina
T
4

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.

Technology answered 1/2, 2019 at 20:28 Comment(0)
M
3

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().

Malkamalkah answered 7/9, 2019 at 19:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.