我只想在图例中显示线条(而不是十字)。 picture of plot with cross
example.dat <- data.frame(distance=c("short","medium","short","medium"),ubiquity = c(0.09,0.09,0.30,0.30),deltaAUC = c(-0.0095,-0.039,-0.0206,-0.045),lower=c(-0.0888,0.0299,-0.0089,0.09),upper=c(0.165,0.284,0.174,0.273))
ggplot(example.dat, aes(ubiquity, deltaAUC,colour=distance)) +
geom_line(aes(group=distance),size=1,position=position_dodge(0.02))+
geom_point(position=position_dodge(0.02),size=0)+
geom_linerange(aes(ymin=-(plogis(lower)-0.5), ymax=- (plogis(upper)-0.5)),position=position_dodge(0.02),size=1)+
theme_bw()+
theme(plot.title=element_text(margin=margin(t=40,b=-20),hjust=0.5),
legend.position = c(0.8, 0.2),
legend.background = element_rect(color = "black",size = .3),
legend.title=element_blank())+
guides(colour = guide_legend(override.aes = list(shape=0,linetype=1)))+
ggtitle(NULL)+
ylab(NULL)+
xlab(NULL)
最佳答案
将 show.legend = FALSE
添加到您不需要图例的 geom
,例如:
geom_linerange(aes(ymin = -(plogis(lower)-0.5), ymax = - (plogis(upper)-0.5)),
position = position_dodge(0.02),
size = 1,
show.legend = FALSE)
关于r - ggplot 将图例中的符号覆盖为直线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51050279/