배경 텍스트 추가하기
이전 레슨에서는 주택 가격 지수와 실질 GDP의 애니메이션 버블 차트를 다듬었습니다. 이번 연습에서는 애니메이션 배경에 연도를 표시해 그래픽을 더 다듬어 보겠습니다.
이 연습은 강의의 일부입니다
R로 배우는 plotly 중급 인터랙티브 데이터 시각화
연습 안내
- 연도를 배경 텍스트로 추가하세요. 텍스트는 좌표 (
200000,450)에 가운데 정렬로 배치하고, 글꼴 색은gray80, 글꼴 크기는150으로 설정하세요. - 슬라이더를 숨기려면
animation_slider()를 사용하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# 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")) %>%
___(___ = ___)