I have the following dataframe and I am trying to visualize and label different topic models across time. Here is my df
dput(head(topic_trends[, c(1, 6)]))
output:
structure(list(topic = c("V1", "V1", "V1", "V1", "V1", "V1"),
month_year = structure(c(2021.91666666667, 2022, 2022.08333333333,
2022.16666666667, 2022.25, 2022.33333333333), class = "yearmon")), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))
#labeling the topics
# topic_labels <- c(
# "1" = MAGA",
# "2" = "Alex Jones",
# "3" = "ANTIFA"
# )
graph code:
#visualize topics over time
ggplot(topic_trends, aes(x = month_year, y = avg_gamma, color = factor(topic))) +
geom_line() +
scale_color_manual(values = c("1" = "blue", "2" = "red", "3" = "green"),
labels = topic_labels) +
labs(x = "", y = "Average Topic Proportion", color = "Topic") +
theme_minimal() +
ggtitle("Topic Trends Over Time")
But the labels are not displayed in the graph and the lines all have the same color, rather than the coded colors in the ggplot code above.
output: