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.
Questo esercizio fa parte del corso
Intermediate Interactive Data Visualization with plotly in R
Istruzioni dell'esercizio
- 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.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# 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")) %>%
___(___ = ___)