Hi:
Here are two ways you could go about this, but I would slightly
rewrite your data frame code to avoid automatic conversion of color
strings to factor.
test <- data.frame(plot=c(1,1,1,1,1,2,2,2,2,2),
lat=c(1,1,2,2,1,3,3,4,4,3),
long=c(1,2,2,1,1,3,4,4,3,3),
poly.color=rep(c("#CE3B57", "#BA5D58"), each = 5),
stringsAsFactors = FALSE)
1. Use scale_fill_manual() as you did in your later posts.
2. A less well-known feature is scale_*_identity(), where the colors
themselves are the breaks and values (and the default labels. This
also works:
ggplot(test) +
geom_polygon(aes(x=long, y=lat, fill= poly.color)) +
scale_fill_identity(guide = "legend", labels = c(1, 2)) +
labs(fill = "plot")
By default, scale_identity() does not produce a guide, so you have to
specify the type of guide you want before you can change any of the
scale's properties (in this case, the labels).
Dennis