我试图在google地图上为我的数据绘制轮廓热图。但是,我发现一个持久的问题。
当我在不添加地理地图的情况下创建等高线图时,该功能正常工作并给我以下图形。
CODE
library(ggplot2)
library(ggmap)
latlonpostcandat<-data.frame(cbind(c(47.00735, 47.36228, 47.40399, 48.08666,47.57196,
47.63742),
c(-52.95892, -53.29399, -52.79987, -52.89429, -53.27813, -52.92653),
c(86301.14, 1017390.34, 2662332.67, 473139.73, 8251899.99, 167512.52)))
names(latlonpostcandat)<-c('Longitude','Latitude','Trans_Amt')
ggplot(latlonpostcandat,aes(x = Longitude, y = Latitude, z = Trans_Amt)) +
geom_contour()
现在,当我做同样的事情但执行以下代码时:
map <- get_map(location='Canada', zoom=3, maptype = "terrain",
source='google',color='color')
ggmap(map)+
ggplot(latlonpostcandat, aes(x = Longitude, y = Latitude, z = Trans_Amt)) +
geom_contour()
我收到以下错误:Error: Don't know how to add o to a plot
我觉得这里有一些巧妙的错误阻止我得到我期望的结果。
感谢您的时间。