How do I configure a ggplot2 step plot so that when the value being plotted is over a certain level it is one colour and when it is below that certain level it is another colour? (Ultimately I would like to specify the colours used.)
My first thought was that this would be a simple issue that only required me to add a column to my existing data frame and map this column to the aes() for geom_step(). That works to a point: I get two colours, but they overlap as shown in this image:

I have searched SO for the past several hours and found many similar but not identical questions. However, despite trying a wide variety of combinations in different layers I have not been able to resolve the problem. Code follows. Any help much appreciated.
require(ggplot2)
tmp <- structure(list(date = structure(c(1325635200, 1325635800, 1325636400,
1325637000, 1325637600, 1325638200, 1325638800, 1325639400, 1325640000,
1325640600, 1325641200, 1325641800, 1325642400, 1325643000, 1325643600,
1325644200, 1325647800, 1325648400, 1325649000, 1325649600, 1325650200,
1325650800, 1325651400, 1325652000, 1325652600, 1325653200, 1325653800,
1325654400, 1325655000, 1325655600, 1325656200, 1325656800), tzone = "", tclass = c("POSIXct",
"POSIXt"), class = c("POSIXct", "POSIXt")), Close = c(739.07,
739.86, 740.41, 741.21, 740.99, 741.69, 742.64, 741.34, 741.28,
741.69, 741.6, 741.32, 741.95, 741.86, 741.02, 741.08, 742.08,
742.88, 743.19, 743.18, 743.78, 743.65, 743.66, 742.78, 743.34,
742.81, 743.31, 743.81, 742.91, 743.09, 742.47, 742.99)), .Names = c("date",
"Close"), row.names = c(NA, -32L), class = "data.frame")
prevclose <- 743
tmp$status <- as.factor(ifelse (tmp$Close> prevclose, "Above", "Below"))
ggplot() +
geom_step(data = tmp,aes(date, Close, colour = status))
You need
group = 1inaes:Maybe you want to do something like this: