September 10, 2026
If you like particular theme and want to use it for all of your visualizations, use theme_set() in a code chunk at the top of your document, e.g….
… and R will apply that theme to all of the visualizations in your document.
Produce this scatter plot… Then try different themes.
First step, add a horizontal line using geom_hline()…
Second step, the annotation with annotate()…
First step, add a horizontal line using geom_hline()…
Second step, add the annotation with annotate()
Any ggplot can become an interactive chart with one function: ggplotly() from the plotly package.
By default plotly shows every mapped variable. Use tooltip = to pick which ones, and add aes(label = ) for a variable that is not already in the plot…
ggplotly()tooltip = to choose which variables appearaes(label = country) so you can show the country nameTwo additions: transition_states() picks the variable to animate over, and {closest_state} puts it in the title.
library(gganimate)
flfp_gdp_ts <- wb_data(indicators, mrv = 25) |> # 25 most recent years
left_join(select(wb_countries(), c(iso3c, region)), by = "iso3c") |>
drop_na() |> rename(year = date)
ggplot(flfp_gdp_ts, aes(x = gdp_pc, y = flfp)) +
geom_point(aes(color = region)) +
scale_x_log10(labels = scales::label_dollar()) +
scale_y_continuous(labels = scales::label_percent(scale = 1)) +
transition_states(year) +
labs(title = "Wealth and female labor force participation, {closest_state}") +
scale_color_viridis_d(option = "plasma", end = .7)