A geom that draws a rectangle.
Default statistic: stat_identity
Default position adjustment: position_identity
The following example shows how a data frame can define multiple rectangles. We add an extra layers to label each rectangle (with the observation number).
d=data.frame(x1=c(1,3,1,5,4), x2=c(2,4,3,6,6), y1=c(1,1,4,1,3), y2=c(2,2,5,3,5), t=c('a','a','a','b','b'), r=c(1,2,3,4,5)) ggplot() + scale_x_continuous(name="x") + scale_y_continuous(name="y") + geom_rect(data=d, mapping=aes(xmin=x1, xmax=x2, ymin=y1, ymax=y2, fill=t), color="black", alpha=0.5) + geom_text(data=d, aes(x=x1+(x2-x1)/2, y=y1+(y2-y1)/2, label=r), size=4) + opts(title="geom_rect", plot.title=theme_text(size=40, vjust=1.5))