Byron Pop
Byron Pop

Reputation: 31

Changing color of points in R Sentimentr plot() function

I am trying to change the color of the red points in the plot() function used by the Sentimentr package. I think plot() returns a ggplot2 object, but when I try to add parameters to the plot() function (e.g., color = 'blue' or fill = 'blue'), nothing changes. Any help is appreciated! Reproducible example below.

enter image description here

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

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

plot(out)

Upvotes: 0

Views: 67

Answers (1)

pascal
pascal

Reputation: 1085

After starting your R session, type:

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

change everything what you want, e.g. change "red" to "blue" on line 21 to change the color of the points. Then repeat what you did in your example:

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

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

plot(out)

enter image description here

Upvotes: 1

Related Questions