source: https://github.com/wush978/Rtwmap
Plot Data
library(Rtwmap)
## Loading required package: sp
data(village2010)
plot(village2010)
plot of chunk village2010
data(county1984)
plot(county1984)
plot of chunk county1984
data(county2010)
plot(county2010)
plot of chunk county2010
data(town1984)
plot(town1984)
plot of chunk town1984
data(town2010)
plot(town2010)
plot of chunk town2010
Coloring
隨機顏色
data(county1984)
random.color <- as.factor(sample(1:3, length(county1984), TRUE))
color <- rainbow(3)
county1984$random.color <- random.color
spplot(county1984, "random.color", col.regions = color, main = "Taiwan Random Color")
plot of chunk county1984-color
population <- read.csv("population.csv", sep = "\t", header = FALSE)
data(county2010)
rownames(population) <- as.character(population$V2)
population <- population[as.character(county2010$county), "V4"]
col <- heat.colors(max(population))[max(population):1]
county2010$population <- population
spplot(county2010, "population", col.regions = col, main = "Population of Taiwan")
plot of chunk population