Plots Part 3
Your editor J-327D would begin cracking a smile if only his facial expressions weren’t set in some kind of metal alloy. He says your chart is almost ready … it just needs some proper chart titles and axis labels.
Setting chart labels
“ggplot it quite incredible in that it uses "sensible defaults" for most things, but you can override them if you know how. Titles and axis labels are a good example of this.
– J-327D, Galactic News Hub editor
Your editor says you should change the fugly axis labels and add good titles and captions to your chart. He suggests you use labs()
to update and create these.
What J-327D doesn’t quite understand is the robot grading mechanism of the Trials is super particular about how code is written, so you have to use the following words and phrases in your code:
- title … A lot of humans
- subtitle … Of the species in the the Star Wars Universe with more than one unit in our data, humans are the most prefalent. This could indicate a sampling problem.
- caption … By Galactic News Hub
- x axis … Count of species
- y axis … Species
Question for this exercise
species_plot +
geom_text(
aes(label = count_species),
hjust = 1.75,
color = "white"
) +
labs(
title = "A lot of humans",
subtitle = str_wrap("Of the species in the the Star Wars Universe with more than one unit in our data, humans are the most prefalent. This could indicate a sampling problem."),
x = "Count of species", y = "Species",
caption = "By Galactic News Hub"
)
+
species_plot geom_text(
aes(label = count_species),
hjust = 1.75,
color = "white"
+
) labs(
title = "A lot of humans",
subtitle = str_wrap("Of the species in the the Star Wars Universe with more than one unit in our data, humans are the most prefalent. This could indicate a sampling problem."),
x = "Count of species", y = "Species",
caption = "By Galactic News Hub"
)
J-327D says there isn’t much to tell you here. You should set all these text items using the labs()
function. Just make sure you use the extact text phrasing as noted above.
You’re done with this Trial
Great job! Mind tricks don’t work on you! Please inform your JedR Master that you have completed this trial. You are free to attempt the next JedR Trial or continue with JedR Training.