See the examples on pp. 108-109 of the ggplot2 book if you have it.
Here is the relevant code from the ggplot2 book web site:
huron <- data.frame(year = 1875:1972, level = LakeHuron)
ggplot(huron, aes(year)) +
geom_line(aes(y = level - 5), colour = "blue") +
geom_line(aes(y = level + 5), colour = "red")
ggplot(huron, aes(year)) +
geom_line(aes(y = level - 5, colour = "below")) +
geom_line(aes(y = level + 5, colour = "above"))
ggplot(huron, aes(year)) +
geom_line(aes(y = level - 5, colour = "below")) +
geom_line(aes(y = level + 5, colour = "above")) +
scale_colour_manual("Direction",
c("below" = "blue", "above" = "red"))
Notice that in the first plot, there is no legend. This is because the
color aesthetic is set to a single color in each geom_line() layer. In
the other two plots, the colour statement is placed inside the aes()
call, which means that color is now being 'mapped'. The values
ascribed to colour are essentially factor levels that are being
created on the fly which will be used as the labels in the legend key.
The scale_colour_manual() line maps specific color values to the
constructed factor levels rather than the defaults.
You'll need to use a similar device in your plot unless you
reconstruct your input data frame appropriately to avoid it. Had you
provided a reproducible example, it would have been easier to show
you, but if you understand the code above, it may not be necessary.
Dennis
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2