Ajouter un texte d’arrière-plan
Dans la leçon précédente, vous avez peaufiné votre diagramme à bulles animé de l’indice des prix de l’immobilier par rapport au PIB réel. Dans cet exercice, vous allez continuer à l’améliorer en affichant l’année en arrière-plan de l’animation.
Cet exercice fait partie du cours
<cours>Visualisation de données interactive intermédiaire avec plotly en R</cours>Instructions de l’exercice
- Ajoutez l’année comme texte d’arrière-plan. Vous devez centrer le texte au point (
200000,450), définir la couleur de police àgray80, et définir la taille de police à150. - Utilisez
animation_slider()pour masquer le curseur.
Exercice interactif pratique
Essayez cet exercice en complétant ce code d’exemple.
# 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")) %>%
___(___ = ___)