我想用ggmap和ggplotly一起使用,但是这些包无法很好地协同工作。在查找错误消息时,我找到了这里。然而,我不确定aes继承是否可能会出现问题。奇怪的是,用ggmap创建的'myPlot'在RStudio中完美运行,但无法连接到ggplotly。地图数据来自这里。
这两个包能否协同工作呢?(顺便说一下,我不能将其标记为ggplotly,因为我不认为这个包之前曾被引用过。) 代码:
这两个包能否协同工作呢?(顺便说一下,我不能将其标记为ggplotly,因为我不认为这个包之前曾被引用过。) 代码:
lapply(list("ggplot2", "ggmap", "mapproj", "RCurl", "RJSONIO", "plyr"),
require, character.only=TRUE)
# install.packages("devtools")
library("devtools")
# install_github("plotly", "ropensci")
library(plotly)
mapImageData1 <- get_map(location = c(lon = -0.016179, lat = 51.538525),
color = "color",
source = "google",
maptype = "satellite",
zoom = 17)
myMap = ggmap(mapImageData1,
extent = "device",
ylab = "Latitude",
xlab = "Longitude")
py <- plotly("RgraphingAPI", "ektgzomjbx")
res <- py$ggplotly(gg = p_map)
错误信息
res <- py$ggplotly(gg = p_map) 在执行表达式时发生错误,环境中未找到'lon'对象。