我使用了两层geom_point,形状24和默认值。我想在图例中表示形状和各自的描述。任何人都可以指导我如何去做。
total_map<-ggmap(Map)+
geom_point(data = crime_poss_drugs,shape=24,size=6,
aes(x = lon, y = lat,colour=factor(drug_cases)))+
geom_point(data = crime_prod_drugs,aes(x = lon, y = lat,colour=factor(drug_cases)))
提前致谢。
答案 0 :(得分:0)
基本上,您可以将shape=...
加入aes(...)
的调用中。
library(ggplot2)
# make up some data
set.seed(1)
crime_poss_drugs <- data.frame(x=1:10, y=rnorm(10,1), drug_cases=rep(1:2,each=5))
crime_prod_drugs <- data.frame(x=1:10, y=rnorm(10,3), drug_cases=rep(1:2,each=5))
# plot with different shape for each dataset
ggplot() +
geom_point(data=crime_poss_drugs,
aes(x, y, color=factor(drug_cases), shape="POSS"))+
geom_point(data=crime_prod_drugs,
aes(x, y, color=factor(drug_cases), shape="PROD"),size=3)+
scale_shape_manual("Crime",values=c(POSS=24,PROD=16))+
scale_color_discrete("Drug Cases")