我如何在ggplot中为形状美学添加第二个图例?
图表显示了不同的开始类型(形状)、不同的流程(颜色)和不同的
末端类型(再次成形)。目前,我只能显示两个图例:一个用于颜色,一个用于形状(合并了start.type和end.tye)。关于如何获得单独的第三个图例(用于end.type),有什么帮助吗?引入线型作为附加美学不是一个选项。非常感谢。
id <- c("1","2","3")
start.date <- c("01/01/2010","05/05/2004","01/08/2006")
end.date <- c("31/12/2012","05/05/2007","01/09/2009")
start.type <- c("x1","x2","x3")
end.type <- c("y1","y2","y3")
process.type <- c("p1","p2","p3")
u <- data.frame(id,start.date, end.date,start.type,end.type,process.type)
u.plot <- ggplot(u)+
geom_segment(aes(color=process.type, x=start.date, xend=end.date, y=id, yend=id), size=1)+
geom_point(aes(shape=start.type, x=start.date, y=id), size=3)+
geom_point(aes(shape=end.type, x=end.date, y=id), size=3)
plot(u.plot)