I want to plot line segments (to be precise: geom_segment
element) on a geom_rect
with a dark green fill.
I use the following code:
ggplot(data, aes(x=X0, y=Y0, xend=X1, yend=Y1))+
geom_segment(aes(colour=Result)) +
scale_colour_manual(values=c("green", "red"))+
theme(panel.background = element_rect(),
panel.grid.major = element_line( colour = "white") )+
scale_y_continuous(breaks=seq(20,100, by=5))+
geom_rect(aes(xmin = 0, xmax = 100, ymin = 62, ymax = 100),
fill = "grey") +
geom_rect(aes(xmin = 0, xmax = 100, ymin = 60, ymax = 62),
fill = "darkgreen")+
geom_rect(aes(xmin = 0 , xmax = 100, ymin = 50, ymax = 60),
fill = "darkgreen", colour = "white", size = 1)+
geom_rect(aes(xmin = 50, xmax = 50, ymin = 60, ymax = 65),
fill = "yellow", colour = "yellow", size = 4)
... so on.
This gives me:
I think the order listed is the order drawn so putting geom_segment last should do it.