Pyramid-like bar chart for climate change barriers

I was scrolling through the Independent and got hooked on a graph displaying the percentage of people’s concerns regarding climate change by country, and was extremely surprised by the results. UK and US lag far behind countries including China in wanting their governments to pursue a meaningful commitment to successfully address climate change.

newplot

library(ggplot2)
library(grid)
library(plyr)

dta<-
structure(list(country = structure(c(15L, 3L, 4L, 5L, 14L, 6L,
10L, 12L, 1L, 2L, 7L, 8L, 9L, 11L, 13L, 15L, 3L, 4L, 5L, 14L,
6L, 10L, 12L, 1L, 2L, 7L, 8L, 9L, 11L, 13L), .Label = c("Australia",
"China", "Denmark", "Finland", "France", "Germany", "Hong Kong",
"Indonesia", "Malaysia", "Norway", "Singapore", "Sweden", "Thailand",
"UK", "US"), class = "factor"), issue = c("Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage who think climate \nchange is 'not a serious problem' ",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change",
"Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change"
), perc = c(32L, 14L, 23L, 10L, 26L, 11L, 22L, 18L, 11L, 4L,
5L, 3L, 2L, 5L, 6L, -17L, -4L, -8L, -3L, -7L, -4L, -10L, -8L,
-3L, -1L, -1L, -1L, -1L, -1L, -1L)), .Names = c("country", "issue",
"perc"), row.names = c(NA, -30L), class = "data.frame")

p <- ggplot(dta, aes(reorder(country,perc),perc,fill=issue)) +
geom_bar(subset = .(issue == "Percentage who think climate \nchange is 'not a serious problem' "), stat = "identity",colour="black",alpha=0.5) +
annotate("text",x = 16.5, y = -12,label=dta$issue[16], fontface="bold")+
geom_bar(subset = .(issue == "Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change"),colour="black", stat = "identity",alpha=0.5) +
annotate("text",x = 16.5, y = 15,label=dta$issue[1], fontface="bold")+
scale_fill_manual(values = c("#F7320B", "#2BC931"))+
geom_text(subset = .(issue == "Percentage who think climate \nchange is 'not a serious problem' "),
aes(label=perc.a), position="dodge", hjust=-.35)+
geom_text(subset = .(issue == "Percentage that want their country's strategy not to agree \nto any international agreement that addresses climate change"),colour="black", stat = "identity",aes(label=perc.b), position="dodge", hjust=2)+
coord_flip() +
xlab("")+
ylab("")+
scale_x_discrete(expand=c(0.2,0.55))+
scale_y_continuous(limits=c(-22,32),
breaks = c(-17,-10,0,10,32),
labels = paste0(as.character(c(17,10,0,10,32), "%")))+
theme(axis.text.y  = element_text(size=13,hjust=1),
axis.text = element_text(colour = "black"),
plot.background = element_blank(),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_blank(),
legend.background =element_rect("white"),
legend.position="none",
strip.background = element_rect(fill = "white", colour = "white"),
strip.text.x = element_text(size = 13))

ggsave("newplot.pdf",p,scale=2)

Advertisements

Author: acarioli

is a PostDoc at the Geography and Environment department of the University of Southampton, WorldPop project team. She is also affiliated researcher at CED, UAB and Dondena Centre. Her interests include spatial econometrics and modeling, bayesian methods, machine learning processes, forecasting, micro-data simulation, and data visualization. Demo-traveler, Mac enthusiast, R zealot and Rladies member.