I prepare to draw a schematic plot rather than data visulization.So the importing data is not data.frame
. Most of lines add by manual operation (ie. geom_segment
, geom_vline
). I found it hard to display the linetype legend or color legend. Maybe it do not accord with ggplot ideology, but it is convenient way to adding singular line without combining to data.frame
.
x <- 1:10
y <- 2:11
plt <- ggplot()+
geom_point(aes(x=x,y=y),shape=1,color='red',show.legend=TRUE)+
geom_line(aes(x=x,y=y),linetype=2,color='green')+
geom_segment(aes(x=Inf,y=y[3],xend=x[3],yend=y[3]),color='blue',linetype=5)+
geom_vline(xintercept=x[4],linetype=6,size=2)+
scale_linetype_manual(values=c(2,5,6),labels=c('a','b','c'))