1. Learn
  2. /
  3. Courses
  4. /
  5. Interactive Data Visualization with plotly in R

Exercise

Polishing axis titles

The axes in a subplot can be renamed using the layout() command, just like in a single plot; however, there are multiple x-axes to rename. For example, a 2 x 2 grid of plots requires four x-axis labels:

p %>% # subplot
   layout(
     xaxis = list(title = "title 1"), 
     xaxis2 = list(title = "title 2"),
     xaxis3 = list(title = "title 3"), 
     xaxis4 = list(title = "title 4")
   )

A similar strategy holds for the y-axis labels.

In this example, your task is to polish the axis titles on a subplot. Note that plotly has already been loaded for you.

Instructions

100 XP
  • For the first plot in sp2, use "Global Sales (M units)" for the y-axis label, and leave the x-axis label blank.
  • For the second plot in sp2, label the x-axis "Year" and the y-axis "Global Sales (M units)".