R ggplot2图例中的斜线-几何点和几何线一起

R ggplot2图例中的斜线-几何点和几何线一起,r,ggplot2,R,Ggplot2,我知道我不是第一个在这个舞台上提出问题的人,但我还没有找到解决我这个特别困惑的办法。这是我问题的一个简单例子 data<-data.frame(Est=c(1:20,1:20),Measured=c(1:5,5:9,1:6,3:6,1:6,3:6,1:4,4,4:8),variable=c(rep("Plot1",20),rep("Plot2",20))) p<-ggplot(data,aes(y=Est,x=Measured,shape=variable)) p<-

我知道我不是第一个在这个舞台上提出问题的人,但我还没有找到解决我这个特别困惑的办法。这是我问题的一个简单例子

    data<-data.frame(Est=c(1:20,1:20),Measured=c(1:5,5:9,1:6,3:6,1:6,3:6,1:4,4,4:8),variable=c(rep("Plot1",20),rep("Plot2",20)))

p<-ggplot(data,aes(y=Est,x=Measured,shape=variable))
p<- p + geom_point(stat="identity") +coord_fixed(xlim=c(0,25),ylim=c(0,25)) + theme_bw() 

p #If you plot the figure at this point, the points stand alone in the legend
p<-p+ geom_abline(intercept=0,slope=1,aes(linetype="1:1",color="1:1"),show_guide=TRUE)

p # Once the geom_abline is added, there are lines through the points. :(

p<-p+scale_color_manual(name="Lines",
                        values=c("1:1"="black"))
p<- p + scale_linetype_manual(name="Lines",
                              values=c("1:1"=2))              

p<-p + scale_shape_manual(values=c(0,20), name = "")

p<- p+xlab(expression(paste("Measured volume(",ducks^{3},"",ha^{-1},")",sep=""))) 
p<-p+ ylab(expression(paste("Estimated volume (",ducks^{3},"",ha^{-1},")",sep="")))

数据覆盖美学映射:

p + guides(shape = guide_legend(override.aes = list(linetype = 0)))

我总是试图通过将它们设置为
NULL
来覆盖美学,但出于某种原因,直觉通常是错误的。

覆盖美学映射:

p + guides(shape = guide_legend(override.aes = list(linetype = 0)))

我总是试图通过将它们设置为
NULL
来覆盖美学,但出于某种原因,直觉通常是错误的。

完美!谢谢你,乔兰!很 完美!谢谢你,乔兰!