Original


Source: The Washington Post.(2015)


Objective

The objective of the data is to highlight the countries that are least religious against the most religious countries. On identifying these countries, the countries’ trade, art, culture or business can be studied. The fact that the map is posted in The Washington Post- an American daily newspaper, the targeted audience is the general public.

The visualisation chosen had the following three main issues:

  • The visualisation is generated using surveyed data of 65 countries out of 195 countries in the world. Hence, this does not depict “World’s least religious countries” exactly as only 33% of the countries are taken into consideration.
  • The visualisation does not have any mention of the names of the Countries which demands the audience to have complete knowledge of World map and the location of countries in it. Therefore, someone not having 100% map reference knowledge will have difficulty in locating the countries.
  • Legend scale is inappropriate. The scale is divided quarterly which provides a high-level view and not detailed percentage of non-religious people in each country.

Reference

Code

The following code was used to fix the issues identified in the original visualisation.

library(maptools)
library(dplyr)


setwd("~/Documents/Rmit- Classes/Data Visualisation and Comm/Assignment_2")
#Reading main dataset(data.frame)
Religion <- read.csv("Religion_Data.csv")

#Reading the spatial shape File
library(rgdal)
Country <- readOGR(dsn= "Coordinate",layer="TM_WORLD_BORDERS-0.3", verbose=FALSE)

#Changing the header for merging
names(Religion) <- c("name", "Not_Religious_%", "Religious_%", "Total_Population")

#merge both files
Country_religion <-sp::merge(Country,Religion, by="name")

# Create a color palette for the map:

library(leaflet)
palette <- colorNumeric( palette="viridis", domain=Country_religion$`Not_Religious_%`, na.color="transparent")

# Create a color_palette with personalised bins.
library(RColorBrewer)
mybins <- c(0,20,30,40,50,60,70,80,90,100)
palette <- colorBin( palette="YlOrRd", domain=Country_religion$`Not_Religious_%`, na.color="transparent", bins=mybins)

# Creating Label text:
library(htmlwidgets)
library(htmltools)

Lab_Text <- paste(
  "Country: ", Country_religion@data$name,"<br/>", 
  "Population: ",round(Country_religion@data$Total_Population,2), "<br/>", 
  "Atheist %: ", Country_religion@data$`Not_Religious_%`, 
  sep="") %>%
  lapply(htmltools::HTML)

#Add main title
title <- tags$div(
  HTML('<h3>World\'s Least Religious Countries</h3>')
)

# Final Map
library(leaflet)
Final<- leaflet(Country_religion) %>% 
  addTiles()  %>% 
  setView( lat=10, lng=0 , zoom=2) %>%
  addPolygons( 
    fillColor = ~palette(Country_religion$`Not_Religious_%`), 
    stroke=TRUE, 
    fillOpacity = 0.9, 
    color="white", 
    weight=0.3,
    label = Lab_Text,
    labelOptions = labelOptions( 
      style = list("font-weight" = "normal", padding = "3px 8px"), 
      textsize = "13px", 
      direction = "auto"
    )
  ) %>%
  addLegend( pal=palette, values=~Country_religion$`Not_Religious_%`, opacity=0.9, 
             title = "NonReligious %", position = "bottomright" ) %>% 
  addControl(title, position= "topright")

Data Reference

Reconstruction

The following plot fixes the main issues in the original visualisation.