I'm creating a rather wide plot of means with SEM error bars. When I do this, there are many different levels of the discrete x variable that I want to make it easier to reference the "control" values. In order to do this, I want to create a rectangle that goes across the screen that represents the mean-se and mean+se of each control (there are two in my original dataset). I cannot figure out how to do this with a discrete scale. Complicating this is the fact that I am reordering my variables on the fly based upon the mean, so, "a" and "d" might not be the ends of the scale.
When I use Inf for the xmin/max in geom_rect() I get complaints about discrete/continuous combinations. Is there an "Inf" for a discrete scale? Is there a way to do this?
#Hopefully reproducible example
require(ggplot2)
data<-data.frame(name=c("a", "b", "c", "d"), mean=c(5, 9, 7, 11), se=c(1.2, 0.9, 3, 2))
ggplot()+
#layer creating a rectangle across the plot
#geom_rect(data=data[data$name=="b",], aes(xmin=-Inf, xmax=Inf, ymin=mean-se, ymax=mean+se), fill='white', alpha=0.2)+
#Using the above line I get the following: Error: Discrete value supplied to continuous scale
geom_pointrange(data=data, aes(x=reorder(name, mean), y=mean, ymin=mean-se, ymax=mean+se))+
labs(y="b*")+
opts(axis.text.x = theme_text(angle = 90))