Interactive and static plots of media platform active users from 2005 to 2019.
Start with the data
Group_by media platforms so there will be a “river” for each platform
Use mutate to round active users so only 2 digits will be displayed when you hover over it.
Use mutate to change Year so it will be displayed as end of year instead of beginning of year
Use e_charts to create an e_charts object with Year on the x axis
Use e_river to build “rivers” that contain active users by media platforms. The depth of each river represents the amount of users for each platform.
Use e_tooltip to add a tooltip that will display based on the axis values
Use e_title to add a title, subtitle, and link to subtitle
Use e_theme to change the theme to roma
media_activity %>%
group_by(media_platforms) %>%
mutate(active_users = round(active_users, 2),
Year = paste(Year, "12", "31", sep="-")) %>%
e_charts(x = Year) %>%
e_river(serie = active_users, legend=FALSE) %>%
e_tooltip(trigger = "axis") %>%
e_title(text = "Monthly Active Users, by Media Platform",
subtext = "(in billions of users). Source: Our World in Data",
sublink = "https://ourworldindata.org/social-connections-and-loneliness#social-media-started-in-the-early-2000s",
left = "center") %>%
e_theme("roma")
Start with the data
Use ggplot to create a new ggplot object. Use aes to indicate that Year will be mapped to the x axis; active_users will be mapped to the y axis; media_platforms will be the fill variable
geom_area will display active_users
scale_fill_discrete_divergingx is a function in the colorspace package. It sets the color palette to roma and selects a maximum of 12 colors for the different media platforms
theme_classic sets the theme
theme(legend.position = “bottom”) puts the legend at the bottom of the plot
labs sets the y axis label, fill = NULL indicates that the fill variable will not have the labelled media_platforms
media_activity %>%
ggplot(aes(x = Year, y = active_users,
fill = media_platforms)) +
geom_area() +
colorspace::scale_fill_discrete_divergingx(palette = "roma", nmax =19) +
theme_classic() +
theme(legend.position = "bottom") +
labs( y = "in billions of users",
fill = NULL)
These plots show a steady increase as well as decrease in active users for different platforms since 2005. Active users for Facebook, Twitter, and Pinterest continued to increase going into 2019.