Adding background text
In the previous lesson, you polished your animated bubble chart of housing price index against real GDP. In this exercise, you will continue to polish this graphic by displaying the year in the background of the animation.
Deze oefening maakt deel uit van de cursus
Intermediate Interactive Data Visualization with plotly in R
Oefeninstructies
- Add the year as background text. You should center the text at the point (
200000,450), set the font color togray80, and set the font size to150. - Use
animation_slider()to hide the slider.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Add the year as background text and remove the slider
us_economy %>%
plot_ly(x = ~gdp, y = ~house_price, hoverinfo = "text", text = ~state) %>%
add_text(x = ___, y = ___, text = ___, frame = ___,
textfont = list(color = ___(___), size = ___)) %>%
add_markers(size = ~population, color = ~region,
frame = ~year, ids = ~state,
marker = list(sizemode = "diameter", sizeref = 3)) %>%
layout(xaxis = list(title = "Real GDP (millions USD)", type = "log"),
yaxis = list(title = "Housing price index")) %>%
___(___ = ___)