I have 2 data frames and I would like to create one plot where the data from the "now" data frame is a bar chart and the data from the "historical" data frame is a line chart.
I have created the bar chart but am not sure how to overlay the data from the "historical" data frame as a lines and have there only be one legend. The Legend should contain 4 elements: a_today, b_today, a_hist, b_hist
historical= data.frame(x = c("10:00","10:30","11:00","10:00","10:30","11:00"), value= c(1,2,3,4,5,6), category = c("a_hist","a_hist","a_hist","b_hist","b_hist","b_hist"))
historical
now= data.frame(x = c("10:00","10:30","10:00","10:30"), value= c(8,6,10,10), category = c("a_today","a_today","b_today","b_today"))
now
ggplot(now, aes(x=x, y=value, fill = category )) +
geom_bar(stat= "identity",position=position_dodge()) + ggtitle("this is my plot")
ggplot(now, aes(x=x, y=value, fill = category )) + geom_bar(stat= "identity",position=position_dodge()) + ggtitle("this is my plot") +
geom_line(data = historical, aes(x=x, y=value, group = category, col=category)) + scale_color_discrete(guide = F) +
scale_fill_manual(values = c("a_hist"= "green","b_hist" ="salmon","a_today" = "yellow", "b_today" = "red") ) + geom_point()
Any idea how to get points to show up on the line properly and not on the bar chart?