library(ggplot2) library(maps) library(mapproj) # read in points mpc <- read.csv("meancentersWGS.csv") # plot the means, grouped by population subgroup p <- qplot(MEAN_X, MEAN_Y, data=mpc, colour=factor(POP), size=I(1.2), xlab="", ylab="", main="US Mean Population Centers 1790-2000") # use eastern section of US as basemap us.east = c("minnesota","iowa","missouri","arkansas","louisiana","wisconsin","illinois","tennessee","michigan","maine","indiana","kentucky","alabama","ohio","georgia","massachusetts","vermont","new hampshire","mississippi","rhode island","new york","conneticut","pennsylvania","new jersey","deleware","west virginia","virginia","maryland","north carolina","south carolina","florida") p <- p + borders("state", region=us.east, size=0.2, colour = I("grey65")) # transform coordinates into Albers Equal Area p <- p + coord_map(project="albers", lat0=37.5, lat1=29.5) # add path for all three population groups p <- p + geom_path(size=0.2) # make legend and colors nicer p <- p + scale_colour_brewer(pal="Set1", name = "Population Group", breaks=c("African-African/American", "Enslaved", "Total"), labels =c("African, African-American", "Enslaved (1790-1860)", "Total (1790-2000)")) # add labels for 1790.. p <- p + annotate("text", x = subset(mpc, POP == "African-African/American")[1,2], y = subset(mpc, POP == "African-African/American")[1,3], label = subset(mpc, POP == "African-African/American")[1,1], size=2.5, hjust = 0.4, vjust = -0.5) # ... 2000.. p <- p + annotate("text", x = subset(mpc, POP == "African-African/American")[length(subset(mpc, POP == "African-African/American")),2], y = subset(mpc, POP == "African-African/American")[nrow(subset(mpc, POP == "African-African/American")),3], label = subset(mpc, POP == "African-African/American")[nrow(subset(mpc, POP == "African-African/American")),1], size=2.5, hjust = 3.5, vjust = -1) # ... and 1900 p <- p + annotate("text", x = subset(subset(mpc, POP == "African-African/American"), CENSUSYR == 1900)[1,2], y = subset(subset(mpc, POP == "African-African/American"), CENSUSYR == 1900)[1,3], label = subset(subset(mpc, POP == "African-African/American"), CENSUSYR == 1900)[1,1], size=2.5, hjust = 1.2, vjust = 1) # plot it! pdf() p dev.off()