不完全确定为什么ggplot使用渐变为图例而不是单个点来显示差异。如何使用两种不同的颜色来显示不同的关系?
dat <- structure(list(year = c(1944L, 1945L, 1946L, 1947L, 1947L, 1948L,
1948L, 1949L, 1949L, 1950L), state = c("montana", "montana",
"montana", "montana", "nebraska", "montana", "nebraska", "montana",
"nebraska", "montana"), x = c(28, 26, 25, 27, 49, 39, 57.3, 38,
55, 41), value = c(2, 1, 1, 2, 1, 1, 1, 2, 1, 1)), .Names = c("year",
"state", "x", "value"), row.names = c(NA, -10L), class = c("tbl_df",
"data.frame"))
ggplot(dat, aes(year, x)) + geom_point(aes(color = value))