Image Credit: Brian Yurasits on Unsplash

# Top 10 Nations Dumping Plastic in the Oceans

I came across this Science article someone shared on Twitter: Plastic waste inputs from land in to the ocean

In this post I am going to make a bar graph using the top 10 countries listed in Table 1. Here is the screenshot of that table.

The ranking in the table is based on the last column. As that column shows interval estimates, I decided use the midpoints of those intervals. Here is the final result:

Below I produce the code for making this plot. The only new thing in this plot is the flags at the bottom of the bars. I am using ggimage package to put those flags there. I got the flags from this website: https://www.countryflags.com/en/

In the code below, I first created a data frame that has the paths to the files with country flags. Next I added a column for the country names. This was followed by the rank, and then the marine plastic waste. I multiplied plastic waste by 1,000, thereby converting it from million metric tons to thousand metric tons.

I created a “colors” vector with the colors I want to use. I will call this vector in the ggplot code.

library(ggplot2)
library(ggimage)
library(hrbrthemes)
library(here)

dt <- data.frame(img = list.files(here::here('Flags_Wave'), full.names = TRUE),
country = c('Bangladesh', 'China', 'Egypt', 'Indonesia',
'Sri Lanka', 'Malaysia', 'Nigeria',
'Philippines', 'Thailand', 'Vietnam'),
rank = c(10, 1, 7, 2, 5, 8, 9, 3, 6, 4),
plastic = c(215, 2425, 270, 885, 440, 255, 235, 515, 280, 505)
)

colors <- c("#ED3B43", "#B48EAD", "#A3BE8C", "#EBCB8B", "#D08770",

ggplot(dt, aes(reorder(country, rank), plastic)) +
geom_col(
aes(fill = as.factor(rank),
color = as.factor(rank)
),
show.legend = FALSE) +
geom_image(y = -150,
aes(image = img),
size = rep(0.085, 10),  # Play with this a bit
by = "width") +
scale_fill_manual(values = colors) +
scale_color_manual(values = colors) +
scale_y_continuous(labels = scales::comma) +
expand_limits(y = -150) +
labs(x = "", y="Marine Plastic Waste in '000 Metric Tons (2010)",
title = 'Top 10 Nations to Dump Plastic in the Oceans ',
caption = "© Ashwin Malshe 2019
Source: Jambeck et al. (2015), 'Plastic waste inputs from land into the ocean,' Science") +
theme_modern_rc()