how to remove line from fill scale legend using geom_vline and geom_histogram r ggplot2

柔情痞子 提交于 2019-12-05 19:39:38

One workaround is to change the order of geom_histogram() and geom_vline(). Then add another geom_vline() without aes(), just giving xintercept= and linetype=. This will not remove lines but will hide them under the color legend entries.

ggplot(data=df1, aes(x=rating, fill=cond)) + 
  geom_vline(data=df2,aes(xintercept=x,linetype=factor(cond)),
             show_guide=TRUE) +
  geom_histogram(binwidth=.5, position="dodge") +
  geom_vline(xintercep=df2$x,linetype=c(1,3))+
  labs(fill='Stochastic',linetype='Deterministic')

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!