Let's assume I have the following dataframe:
df = data.frame(Date = seq(as.Date("2001-01-01"), as.Date("2020-12-31"), by = "day"),
Data = randn(length(seq(as.Date("2001-01-01"), as.Date("2020-12-31"), by = "day")),1),
stringsAsFactors = F)
and a vector of words:
key_words = c("ciao", "bye", "thanks", "for", "your", "help", "SO", "is", "amazing", "really")
I would like to plot it with ggplot by adding, in the second y-axis the vector of words key_words
, similarly to the figure below:
This is the simple code to plot the graph in ggplot:
ggplot(df) + geom_line(aes(x = Date, y = Data), col = "blue") + labs(y = "", x = "") + theme_classic()
Is there anyone who can help me add key_words
as a column in the figure above?
Thanks!