Removing a dot from ggplot2 legend

Code example:

EmigProb<-c(rep(seq(0.1,0.8,length=5),4),rep(seq(0.1,0.8,length=5),4)) RemainEmigProb<-c(rep(0.2,5),rep(0.4,5),rep(0.6,5),rep(0.8,5),rep(0.2,5),rep(0.4,5),rep(0.6,5),rep(0.8,5)) Value<-rnorm(40,5,3) Parameter<-c(rep("Survival",20),rep("Resight",20)) fakedata<-data.frame(EmigProb=EmigProb,RemainEmigProb=RemainEmigProb,Value=Value,Parameter=Parameter) q <-ggplot(fakedata,aes(EmigProb,Value,shape=factor(RemainEmigProb),colour=factor(Parameter),linetype=factor(RemainEmigProb)))+scale_colour_discrete("Parameter")+scale_linetype_discrete("Remain Emigrant Probability")+scale_shape_manual("Remain Emigrant Probability",values=c(0,5,6,15)) q <- q + layer(geom="point") q <- q + layer(geom="line") q 

Example Graph

In this example, is there a way to remove “points” from the “Parameter” legend for “Relaxation” and “Survival”?

+5
r ggplot2
Jul 10 '12 at 16:13
source share
1 answer

Add this to your build command:

 guides(colour = guide_legend(override.aes = list(shape = NA))) 

Details on setting up legends along with lots of great ggplot2 0.9 wisdom can be found here: http://cloud.github.com/downloads/hadley/ggplot2/guide-col.pdf

+13
Jul 10 2018-12-12T00:
source share



All Articles