我无法使用ggmap + ggplot创建带有自定义网格的绘图。这是我正在使用的一些快速生成的样本数据的绘图代码。它成功生成了一个图,但忽略了scale_color_gradientn()
中的自定义颜色。任何建议将不胜感激!
library(ggplot2)
library(reshape2)
library(ggmap)
Lon <- runif(100, -100, -92)
Lat <- runif(100, 34, 45)
Conc <- runif(100, 1, 8)
JECeGRIDLoc <- c(39.2865, -96.1172)
PlotModel1 <- data.frame(Lat, Lon, Conc)
### What I need ###
al1 = get_map(location = c(lon = JECeGRIDLoc[2], lat = JECeGRIDLoc[1]), zoom
= 06, maptype = 'satellite')
al1MAP = ggmap(al1)
al1MAP + geom_tile(data = PlotModel1, aes(x = Lon, y = Lat, fill = Conc)) +
scale_fill_gradient(limits=c(min(min(PlotModel1$Conc),
min(PlotModel2$Conc)),
max(max(PlotModel1$Conc), max(PlotModel2$Conc))), low = "yellow", high =
"red") +
scale_color_gradientn(colors = c("purple", "red", "orange", "yellow",
"green")) +
xlab("Longitude") +
ylab("Latitude") +
ggtitle("Jeffrey Energy Center (2012): \n eGRID Model Dispersion Area")
### Additional example (does not work) ###
ggplot(data = PlotModel1, aes(x = Lon, y = Lat, fill = Conc)) +
geom_point() +
scale_color_gradientn(colors = c("purple", "red", "orange", "yellow",
"green"))