简体   繁体   中英

ggplot2 legend showing point on top a line: how to prevent it?

How to prevent ggplot2 from having a legend like this

在此处输入图像描述

I have the following code

ggplot(dStat_cCode[AgentID==1 & SimulationID==1,,], aes(x=lag, y=log10(em_autoCorr_cCode), colour = "data")) +
  geom_point(size=1)+
  #geom_line(data = d[N==specN & abs(displacement) < episodeLength & AgentID==specAgentID,], aes(alpha = (AgentID==specAgentID)))+
  stat_summary_bin(fun.data = mean_se, bins=50)+
  #coord_trans(y = "log10")+
  geom_line(aes(y=log10(fem_autoCorr_cCode), colour = "fit"), size=1, alpha=1)+
  scale_color_manual(values = c("black", "#fc8d62"))+
  scale_fill_manual(values = c("black", "#fc8d62"))

And I want it to have the usual type of legend for a line, not a point on top of a line as above.

All of the geom_ and stat_ layers in ggplot2 take an argument show.legend which defaults to NA . Set it to FALSE for any layer you do not want to show up in the legend.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM