I have some code written to make a map with USA states and territories. For some territories I need to draw a border outside the title, giving more space to the map. See below a chunk extracted for Hawaii, the grey border is the one that I have right now but I need something similar to the red border that I edited in paint (yes, very bad using paint I know). Any suggestions on how to solve this? I tried to move the border using panel.border without success. The most important task is to add the border giving more space to the plot.
library("choroplethrMaps")
# **************************
# Shapefiles for Hawai
# **************************
data(state.map)
# Subset for Hawaii
map.HI.dat <- subset(map.dat, State=="HI" )
dim(map.HI.dat) #[1] 3 95
map.HI.freq <- data.frame(table(map.HI.dat$state.name))
colnames(map.HI.freq) <- c("region", "n")
class(map.HI.freq$region) #[1] "factor"
map.HI.freq$region <- as.character(map.HI.freq$region)
map.HI.freq$region[map.HI.freq$region=="hawai"] <- "hawaii"
#View(map.HI.freq)
hawaii.st <- subset(state.map, region=="hawaii")
map.HI.freq <- data.frame(region="hawaii",
n=4)
hawaii.map.dat <- plyr::join(hawaii.st, map.HI.freq, by="region")
hawaii.map.dat$brks <- cut(hawaii.map.dat$n,
breaks = c(0, 0.99, 5,10,50,max.breaks),
labels = c("0", "1 - 5", "6 - 50", "51 - 150", paste("151 - ",max.breaks,sep="")),
include.lowest = TRUE)
s2 <-ggplot() +
geom_polygon(data=hawaii.map.dat, aes(x=long, y=lat, group = group, fill=brks), colour="black", size=1, show.legend = FALSE) +
scale_fill_manual(name="",
values = colors.for.maps,
breaks = breaks.for.maps,
drop = FALSE) +
theme(panel.grid = element_blank(),
panel.border = element_rect(colour = "grey50", size = 2, fill=NA),
panel.background = element_blank(),
plot.title = element_text(colour="black", size = 14, face = "bold", hjust=0.5)) +
labs(fill = "Frequencies",
title = "Hawaii", x="", y="") +
scale_y_continuous(breaks=c()) +
scale_x_continuous(breaks=c()) +
coord_map()
s2
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…