Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 带有ggsubplot的ggmap创建空白映射_R_Ggplot2_Ggmap - Fatal编程技术网

R 带有ggsubplot的ggmap创建空白映射

R 带有ggsubplot的ggmap创建空白映射,r,ggplot2,ggmap,R,Ggplot2,Ggmap,我试图在地图上放置一些绘图,但地图上没有显示任何内容。这是一个可复制的例子。第一个图显示了每个子图的外观。第二个不包括贴图,但子地块大小太大。最后是对最终产品的一次尝试。我尝试了许多排列,但这让我卡住了。提前谢谢 library(ggplot2) library(ggmap) library(ggsubplot) pDat <- structure(list(Location = structure(c(13L, 12L, 14L, 14L, 15L, 15L, 16L, 16L, 17

我试图在地图上放置一些绘图,但地图上没有显示任何内容。这是一个可复制的例子。第一个图显示了每个子图的外观。第二个不包括贴图,但子地块大小太大。最后是对最终产品的一次尝试。我尝试了许多排列,但这让我卡住了。提前谢谢

library(ggplot2)
library(ggmap)
library(ggsubplot)

pDat <- structure(list(Location = structure(c(13L, 12L, 14L, 14L, 15L, 15L, 16L, 16L, 17L, 17L, 18L, 19L, 32L, 19L, 19L, 20L, 20L, 20L, 21L, 21L, 21L, 22L, 22L, 22L, 23L, 23L, 24L, 25L, 25L, 26L, 27L, 28L, 28L, 29L, 30L, 30L, 31L), .Label = c("PW-29", "PW-31", "PW-32", "PW-33", "PW-35", "PW-36", "PW-37", "PW-38", "PW-39", "PW-40", "PW29", "SD-03", "SD-03a", "SD-12", "SD-18", "SD-19", "SD-27",   "SD-29", "SD-30", "SD-31", "SD-32", "SD-33", "SD-35", "SD-36", "SD-37", "SD-38", "SD-40", "SD-41", "SD-42", "SD-43", "SD-44", "SD30"), class = "factor"), Lat = c(47.292351, 47.292351, 47.289376,   47.289376, 47.288299, 47.288299, 47.288014, 47.288014, 47.287338, 47.287338, 47.29476, 47.293246, 47.293246, 47.293246, 47.293246, 47.293259, 47.293259, 47.293259, 47.292206, 47.292206, 47.292206,   47.291523, 47.291523, 47.291523, 47.290496, 47.290496, 47.289826, 47.288262, 47.288262, 47.287735, 47.286672, 47.290059, 47.290059, 47.290482, 47.28852, 47.28852, 47.288377), Long = c(-73.098418,    -73.098418, -73.101282, -73.101282, -73.102558, -73.102558, -73.102178, -73.102178, -73.103016, -73.103016, -73.096432, -73.096412, -73.096412, -73.096412, -73.096412, -73.098245, -73.098245, -73.098245, -73.097552, -73.097552, -73.097552, -73.100022, -73.100022, -73.100022, -73.099395,    -73.099395, -73.100051, -73.101199, -73.101199, -73.101895, -73.102629, -73.100954, -73.100954, -73.100184, -73.102246, -73.102246, -73.101477), SBD_ft = c(0, 2, 0, 7, 0, 10, 0, 6, 2, 5, 0, 0.5, 0.5, 0, 2.5, 0.5, 0, 3, 0.5, 0, 2.5, 0.5, 0, 2.5, 0.5, 0, 0, 0.5, 0, 0, 0, 2, 5, 3, 0, 6, 0), SED_ft = c(20, 4, 2, 9, 2, 12, 2, 8, 4, 7, 0.5, 2.5, 2.5, 0.5, 4.5, 2.5, 0.5, 5, 2.5, 0.5, 4.5, 2.5, 0.5, 3.5, 2.5, 0.5, 0.5, 2.5, 0.5, 0.5, 0.5, 4, 7, 5, 2, 8, 2), Cluster = structure(c(3L, 3L, 3L, 4L, 5L, 5L, 2L, 2L, 4L, 5L, 1L, 6L, 6L, 6L, 6L, 1L, 1L, 1L, 6L, 1L, 6L, 4L, 1L, 6L, 1L, 1L, 1L, 5L, 1L, 4L, 1L, 3L, 4L, 3L, 4L, 4L, 4L), .Label = c("1", "2", "3", "4", "5", "6"), class = "factor")), .Names = c("Location",    "Lat", "Long", "SBD_ft", "SED_ft", "Cluster"), row.names = 5:41, class = "data.frame")

BBox<-c(-73.01, 47.28, -73.1, 47.30)
#Base <-get_map(BBox,zoom=13,source='google',maptype = 'hybrid')
Base_z <-get_map(BBox,zoom=15,source='google',maptype = 'hybrid')

fm0<-ggmap(Base_z,legend = "none",
  base_layer=ggplot(aes(x=Long,y=Lat),data=pDat))

# Example subplots
ggplot(pDat,aes(ymin=SBD_ft,ymax=SED_ft,xmin=0,xmax=1,fill=Cluster))+
  facet_wrap(~Location)+
  geom_rect() +
  scale_y_reverse()

# TEST 1, need to control size of subplots
ggplot(pDat)+
  geom_subplot(aes(x=Long,y=Lat,group=Location,
    subplot=geom_rect(data=pDat,aes(ymin=SBD_ft,ymax=SED_ft,xmin=0,xmax=1,fill=Cluster))))

# Final , does not work
fm0+
  geom_subplot(aes(x=Long,y=Lat,group=Location,
    subplot=geom_rect(data=pDat,aes(ymin=SBD_ft,ymax=SED_ft,xmin=0,xmax=1,fill=Cluster))))
库(ggplot2)
图书馆(ggmap)
图书馆(小地块)

pDat I无法在测试1行下复制绘图,我得到
至少有一层必须包含用于刻面的所有变量。
。R3.1.0中有一个with GG子图,您使用的是哪个R版本?