2012-07-10 35 views
5

Ví dụ Code:Loại bỏ yếu tố 'chấm' từ huyền thoại ggplot2

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

Trong ví dụ này, có cách nào để loại bỏ các 'chấm' từ huyền thoại 'Parameter' cho 'Resight' và 'Survival'?

Trả lời

13

Thêm phần này vào lệnh âm mưu của bạn:

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

Chi tiết về huyền thoại tùy biến cùng với rất nhiều tuyệt vời hơn ggplot2 0,9 khôn ngoan có thể được tìm thấy ở đây: http://cloud.github.com/downloads/hadley/ggplot2/guide-col.pdf

+0

Cảm ơn! Đó là động lực tốt để nâng cấp phiên bản ggplot của tôi và cảm ơn liên kết tới những thay đổi mới! – user1399311

Các vấn đề liên quan