Mapping aesthetics to categorical variables
Now let's map both symbol size and shape to GENDER
. To map symbol size to levels of a categorical variable, it is helpful to set the variable as a factor using the
factor()
command.
Then you set up your plot as before, but control your symbol size by adding a new layer using the plus sign: + scale_size_manual(values = c(a, b))
.
The parameters a
and b
have a minimum value of 0 and can be as large as you like. You must select values of a
and b
to produce symbols of the desired size. In the next example, I have chosen symbol sizes of 5 and 7. You may select different sizes, depending on your preferences. You will gain experience very quickly and select the symbol sizes that suit your graphs best. In this case, I introduced some transparency using the alpha = I()
syntax. Transparency assists in the interpretation of graphs that involve a large number of points. Enter the following syntax:
qplot(HEIGHT, WEIGHT_1, data = T, xlab = "HEIGHT (cm)", ylab...