Based on the very helpful answer by joran I was able to come up with this solution for a stable color scale for a boolean factor (TRUE
, FALSE
).
boolColors <- as.character(c("TRUE"="#5aae61", "FALSE"="#7b3294"))
boolScale <- scale_colour_manual(name="myboolean", values=boolColors)
ggplot(myDataFrame, aes(date, duration)) +
geom_point(aes(colour = myboolean)) +
boolScale
Since ColorBrewer isn't very helpful with binary color scales, the two needed colors are defined manually.
Here myboolean
is the name of the column in myDataFrame
holding the TRUE/FALSE factor. date
and duration
are the column names to be mapped to the x and y axis of the plot in this example.