我有以下图表:
dat<-data.frame(name=c("a","b","c"), x=1:3, y=1:3)
ggplot(dat, aes(x=x, y=y))+
geom_point(aes(shape=paste(1:3,": point",name)))+
geom_text(aes(x=x,y=y+0.07), label=1:3)+
scale_shape_manual(values=rep(1,3))+
labs(shape="locations")
我需要将点添加到ggmap,但是当我摆脱ggplot并开始时: geom_point(dat,aes(x = x,y = y,shape = paste(1:3,&#34;:point&#34;,name)))+
我收到错误&#34;错误:提供给连续刻度的离散值&#34;
答案 0 :(得分:2)
library(ggmap)
library(ggplot2)
lis <- get_map("Lisbon,Portugal", zoom=12)
p <- ggmap(lis)
d <- data.frame(lon=c(-9.20, -9.20, -9.12),
lat=c(38.65, 38.80, 38.75),
loc = c('p1', 'p2', 'p3'))
p + geom_point(data=d, aes(x=lon, y=lat),
colour = 'red', size = 8, alpha = .6) +
geom_text(aes(label=loc), data=d, hjust=-1,
fontface = 'bold')
不确定这是否接近您的需求。您应该提供有关数据如何与ggmap相关的更多详细信息(可能提供坐标?)