R 错误:此类型的ggplot没有默认标签放置

R 错误:此类型的ggplot没有默认标签放置,r,ggplot2,direct-labels,R,Ggplot2,Direct Labels,为什么我会犯这个错误?这是我试图为()绘制盐度等值线的R脚本和数据集: 如下所示(前10行): 如果使用默认值: Error in (function (geom, p, L, colvar, ...) : No default label placement for this type of ggplot 如果我指定一个位置放置: direct.label (plot2, "bottom.pieces") 我得到一个不同的错误: 'ggproto' is not an export

为什么我会犯这个错误?这是我试图为()绘制盐度等值线的R脚本和数据集: 如下所示(前10行):

如果使用默认值:

Error in (function (geom, p, L, colvar, ...)  : 
  No default label placement for this type of ggplot
如果我指定一个位置放置:

direct.label (plot2, "bottom.pieces")
我得到一个不同的错误:

'ggproto' is not an exported object from 'namespace:ggplot2'
我做错了什么?

提前谢谢。

所以我在史密斯的帮助下找到了我自己问题的答案。关键是升级到ggplot2 2.1.0,然后使用
stat\u contour()
。下面,我更新了代码,同时添加了一个带有ggmap 2.6.1的底图:

library("ggmap")
library("ggplot2")
library("directlabels")
 ASmap3<-get_map(location= c(lon= -76.16,lat=36.08),zoom=9)
plot1<-ggmap(ASmap3)+stat_contour(aes(Longitude,Latitude,z=Salinity,colour=..level..),data=ASsalinity)
 direct.label(plot1,"bottom.pieces")
库(“ggmap”)
图书馆(“ggplot2”)
库(“directlabels”)

ASmap3因此,在aosmith的帮助下,我找到了自己问题的答案。关键是升级到ggplot2 2.1.0,然后使用
stat\u contour()
。下面,我更新了代码,同时添加了一个带有ggmap 2.6.1的底图:

library("ggmap")
library("ggplot2")
library("directlabels")
 ASmap3<-get_map(location= c(lon= -76.16,lat=36.08),zoom=9)
plot1<-ggmap(ASmap3)+stat_contour(aes(Longitude,Latitude,z=Salinity,colour=..level..),data=ASsalinity)
 direct.label(plot1,"bottom.pieces")
库(“ggmap”)
图书馆(“ggplot2”)
库(“directlabels”)

ASMAP3你想在什么上贴标签?我无法用给定的数据复制此图,但你可能需要
aes(color=saltime)
中的
geom_point
(如果你想给点贴标签),我想用盐度来标记等高线。嗯,我想这是因为你没有将颜色映射到等高线上。看见如果我像你一样使用
direct.label(v2,“bottom.pieces”)
,它对我很有效。我尝试了这个:
>plot1 direct.label(plot1,“bottom.pieces”)
现在我得到了一个不同的错误:
split.default中的错误(x=seq_len(nrow(x)),f=f,drop=drop,…):group length为0,但data length>0
您试图在上面添加标签的是什么?我无法用给定的数据复制此图,但您可能需要
aes(颜色=盐度)
中的
geom_point
(如果您想标记这些点),我想用盐度标记等高线。嗯,我想这是因为你没有把颜色映射到轮廓上。看见如果我像你一样使用
direct.label(v2,“bottom.pieces”)
它对我有效。我尝试了这个:
>plot1 direct.label(plot1,“bottom.pieces”)
现在我得到了一个不同的错误:
split中的错误。默认值(x=seq_len(nrow(x)),f=f,drop=drop,…):组长度为0,但数据长度>0
library("ggmap")
library("ggplot2")
library("directlabels")
 ASmap3<-get_map(location= c(lon= -76.16,lat=36.08),zoom=9)
plot1<-ggmap(ASmap3)+stat_contour(aes(Longitude,Latitude,z=Salinity,colour=..level..),data=ASsalinity)
 direct.label(plot1,"bottom.pieces")