The following are the activity solutions for this chapter.
Chapter 2: Grammar of Graphics and Visual Components
Activity: Applying Grammar of Graphics to Create a Complex Visualization
Steps for Completion:
- Use the commands that we just explored to create the scatterplot.
- For this activity, you will use the gapminder dataset.
- You can use the help command to explore the options.
- To change scales, you will have to use one of the preceding label formats.
- Use labels=scales::unit_format ("K", 1e-3)) for labeling.
Outcome:
The output code is as follows:
ggplot(df, aes(x=gdp_per_capita,y=Electricity_consumption_per_capita))+
geom_point()+
scale_x_continuous(name="GDP",breaks = seq(0,50000...