- Packages I will use to read in and plot the data
- Read the data in from part 1.
regional_tourism <- read_csv(here::here("international-tourist-arrivals-by-world-region.csv"))
Interactive graph
- Start with the data
- group_by region so there will be a “river” for each region.
- use e_charts to create an e_chart object with year on the x-axis
- use e_river to build “rivers” that contain the amount of tourism. The depth of each river represents the International.Tourist.Arrivals.
- 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
regional_tourism %>%
group_by(Region) %>%
e_chart(x = Year) %>%
e_river(serie = International.Tourist.Arrivals, legend = FALSE) %>%
e_tooltip(trigger = "axis") %>%
e_title(text = "Annual Tourist Arrivals by Region", subtext = "Source: Our World in Data", sublink = "https://ourworldindata.org/grapher/international-tourist-arrivals-by-world-region", left = "center") %>%
e_theme("roma")
Static Graph
- 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; International.Tourist.Arrivals will be mapped to the y-axis; Region will be the fill variable
- geom_area will display International.Tourist.Arrivals
- scale_fill_discrete_divergingx is a function in the colorspace package. It sets the color pallet to roma and selects a maximum of 12 colors for the different regions
- 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 Region
These plots show a steady increase in tourist since 2000. The amount of tourist has increased and will continue to.
ggsave(filename = here::here("_posts/2022-05-11-project-part-2/preview.png"))