If instead of points we want to add text, we can use the
geom_text()
or geom_label()
geometries. The following code
murders %>% ggplot(aes(population, total)) + geom_label()
will give us the error message: Error: geom_label requires the
following missing aesthetics: label
. This is because we need to specify
which labels it should print throug the label
aestethic mapping.
1. Rewrite the code above to use abbreviation as the label through
aes
. Save the resulting ggplot object in p_abb
.
2. If we wanted to change the color of the labels to blue, how would we do that?
blue
to murders
.aes
.color
argument in ggplot
.geom_label
.Save your answer in question_2
3. Rewrite the code above to make the labels blue.
Save the resulting ggplot object in p_abb_blue