I was wondering if it is possible to add annotations to a Plotly Animated Gapminder plot? I mean, I don’t need that all the bubbles have annotations, but I would like that some of them had.
Here’s an example, the only country that I want to display the name is China.
library(plotly) library(gapminder) m <- gapminder[gapminder$country == "China", ] a <- list( x = m$gdpPercap, y = m$lifeExp, text = m$country, xref = "x", yref = "y", showarrow = TRUE, arrowhead = 7, ax = 20, ay = -40 ) df <- gapminder fig <- df %>% plot_ly( x = ~gdpPercap, y = ~lifeExp, size = ~pop, color = ~continent, frame = ~year, text = ~country, hoverinfo = "text", type = 'scatter', mode = 'markers' ) %>% add_markers() %>% layout(annotations = a)
The annotation must follow the China marker. Do you know if this is possible?