Map: Where Primate Pets are Legal

Inspired by the sad story of Darwin, known as the “Ikea monkey,” I made this map of state laws regulating the keeping of non-human primates as pets. The data comes from this article in the International Business Times by Roxanne Palmer. The R code to generate the map is below.


library(maps)

# Load pet law data
pet_data = read.table("pet_data.txt", header=FALSE)
names(pet_data) = c("state", "status")

# Translate statuses into colors
col = rep("grey", length(pet_data$status))

color.meanings = data.frame(
	state=c("Illegal", "Legal but effectively banned", 
			"Some species legal", "Legal with permit", "Legal"),
	color=c("#006837","#1A9850","#FDAE61","#F46D43","#D73027"))

for (i in 1:nrow(color.meanings)) {
	this.state = as.character(color.meanings[i,]$state)
	this.color = as.character(color.meanings[i,]$color)
	
	col[pet_data$status == this.state] = this.color
}

# Plot map
out = map("state", interior = FALSE)
int = map("state", boundary = FALSE, col=col, add = TRUE, fill=TRUE)

# Add legend and title
legend("bottomleft", legend = color.meanings$state, 
	col = as.vector(color.meanings$color),
	ncol = 1, cex = .65, lwd = 8, seg.len = 1)
title("Legality of Keeping Primates as Pets")