M3 Discussion 3

Collin Hoskins

2021-09-07

The rainbow color scale is not suggested because:

  • Rainbow color scales are typically difficult for readers to understand, due to the difficulty in comprehending the specific ordering of colors initially when viewing the visualization

  • The rainbow color scale poses an interpretation problem for people who have visual impairments like color blindness

A good alternative is a sequential scheme because it displays a clear gradient from high to low.

Example Using a Dark to Light Representation

require(leaflet)
require(sf)
require(dplyr)
geojson <- read_sf("https://public.opendatasoft.com/explore/dataset/us-state-boundaries/download/?format=geojson&timezone=America/New_York&lang=en")

names(geojson)[names(geojson) == 'basename'] <- 'STATE'

dataset <- data.frame(state.x77)

dataset <- cbind(STATE = row.names(dataset), dataset)

combDF <- inner_join(dataset, geojson)





pal <- colorBin("Oranges", domain = 1:70)


pop <- paste("State: ", combDF$STATE, "<br/> ", 
             "Illiteracy Rate: ", combDF$Illiteracy, "%", "<br/>",
             "High School Graduation Rate: ", combDF$HS.Grad, "%")

n <- leaflet() %>%
  addProviderTiles(providers$CartoDB.Positron) %>%
  addPolygons(data = combDF$geometry, fillColor = pal(combDF$HS.Grad),
              weight = 2, opacity = 1, color = "black",
              fillOpacity = 0.7,
              popup = pop) %>%
  addLegend(pal = pal, values = combDF$HS.Grad, opacity = 0.9, title = "High School Graduation Rate", position = "bottomleft" )

setView(n, -100, 45, zoom = 3)

Example Using Rainbow Scale

require(leaflet)
require(sf)
require(dplyr)

rainbowPal <- colorBin("Spectral", domain = 1:70)

m <- leaflet() %>%
  addProviderTiles(providers$CartoDB.Positron) %>%
  addPolygons(data = combDF$geometry, fillColor = rainbowPal(combDF$HS.Grad),
              weight = 2, opacity = 1, color = "black",
              fillOpacity = 0.7,
              popup = pop) %>%
  addLegend(pal = rainbowPal, values = combDF$HS.Grad, opacity = 0.9, title = "High School Graduation Rate", position = "bottomleft" )

setView(m, -100, 45, zoom = 3)