ggplot2 draws two legends

混江龙づ霸主 提交于 2019-11-28 08:48:39

You have three aesthetics that are mapped to Variable: shape, colour, and linetype. Legends are collapsed together when they have the same title and labels. You have set the title to blank for colour and given it custom labels ("Significant Z-Score" and "Moran's I Z-Score"). You need to do that for linetype and shape as well to get them to collapse all together.

Change

scale_linetype_manual(values=c(1,3)) +

to

scale_linetype_manual(values=c(1,3), name="", labels=c("Signficant Z-Score",   "Moran's I Z-Score")) +

and add

scale_shape_discrete(name="", label=c("Signficant Z-Score", "Moran's I Z-Score")) +

(You can also get rid of the scale_fill_discrete because you don't actually use the fill aesthetic anywhere.)

This gives

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