【发布时间】:2018-03-27 10:37:56
【问题描述】:
所以我有这个大数据框,其中包含一个名为“sentiment”的列,其中列出了不同的值,例如 0,43 或 0,62 等等。
这是 df 中两个条目的最小示例:
df <- dataframe(text=c("This is awesome", "I hate it"), sentiment=c("0.62","0.43"))
我现在想使用ggplot 2 绘制直方图。
我的代码如下所示:
ggplot(test)+
aes(x=sentiment, y=..density..,fill=sentiment)+
geom_histogram(binwidth = 0.01)+
geom_vline(aes(xintercept=mean(sentiment)),
color="blue", linetype="dashed", size=0.5)+
geom_density(alpha=.2,col="#FF6666")
如何将所有低于 0.5 的“情绪”值涂成红色,将所有高于 0.5 的值涂成绿色?
谢谢!
【问题讨论】:
标签: r ggplot2 colors histogram