0

我正在尝试更改Sentimentr 包使用的 plot() 函数中红点的颜色。我认为 plot() 返回一个 ggplot2 对象,但是当我尝试向 plot() 函数添加参数时(例如,color = 'blue' 或 fill = 'blue'),没有任何变化。任何帮助表示赞赏!下面的可重现示例。

在此处输入图像描述

library(sentimentr)
library(magrittr)
library(dplyr)

out <- presidential_debates_2012 %>%
  get_sentences() %$%
  sentiment_by(dialogue, list(person))

plot(out)

4

1 回答 1

1

开始 R 会话后,键入:

trace(sentimentr:::plot.sentiment_by, edit = T)

更改您想要的所有内容,例如在第 21 行将“红色”更改为“蓝色”以更改点的颜色。然后重复您在示例中所做的操作:

library(sentimentr)
library(magrittr)
library(dplyr)

out <- presidential_debates_2012 %>%
  get_sentences() %$%
  sentiment_by(dialogue, list(person))

plot(out)

在此处输入图像描述

于 2021-02-13T09:59:27.600 回答