如何在ggplot2中将颜色添加到构面网格

时间:2019-01-22 19:25:53

标签: r ggplot2 aes

我在ggplot中制作了一个facet_grid,如下所示:

    ggplot(DATASET, aes((jitter(WordCount)),Retweet, group=1))+
      geom_point(aes(alpha=1/150))+
      facet_grid(Dictionary ~ ., margins = TRUE, scales = "free")+
      labs(x = "Word Count", y = "Retweet Count", title = "A")+
      theme_bw()+ 
      theme(legend.position = "none")

enter image description here

如何使每个图形使用不同颜色的点?

作为参考,这是我的数据框的结构:

data.frame':    939006 obs. of  4 variables:
 $ Retweet   : num  1388 762 748 436 342 ...
 $ id        : int  1 2 3 4 5 6 7 8 9 10 ...
 $ Dictionary: Factor w/ 3 levels "Emotional","Moral",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ WordCount : num  1 1 2 2 1 1 3 1 2 1 ...

1 个答案:

答案 0 :(得分:0)

如评论中的回答,为颜色美感分配一个变量。

# after switching to real mode ...
response = self.SayHello_stub.SayHello()
print(response)
>'real'