在这种情况下,如何更改geom_point的颜色?

时间:2016-06-17 21:54:22

标签: r plot ggplot2 data-visualization

以下是代码:

df$ProsperRating..Alpha.<-ordered(df$ProsperRating..Alpha., 
                                  levels = c("AA","A","B","C","D","E","HR"))
ggplot(aes(x=BorrowerAPR,y=LP_InterestandFees),
       data=subset(df,!is.na(ProsperRating..Alpha.)))+
  geom_point(alpha=0.2,aes(color=ProsperRating..Alpha.),position = "jitter")

以下是结果情节: enter image description here

但我需要将这些点的颜色改为蓝调,如下所示: enter image description here

我如何实现这一目标?

1 个答案:

答案 0 :(得分:3)

library(ggplot2)

qplot(x, price, data = diamonds, colour = clarity) +
  scale_colour_brewer(palette="Blues", direction = -1)

产生这个

enter image description here