I have created a graph using this code:
df.1 <- data.frame(
Month = c("Dec-17", "Jan-18", "Feb-18", "Mar-18", "Apr-18", "May-18"),
Total_1 = c(25, 14, 8, 16, 137, 170),
Total_2 = c(3, 2, 3, 2, 18, 27),
Total_3 = c(5, 4, 3, 2, 16, 54)
)
df.1 <- melt(df.1,id.vars = "Month")
#reorder the month column so it isn't alphabetical
df.1$Month <- factor(df.1$Month, levels(df.1$Month)[c(2,4,3,5,1,6)])
#partition my data into the 2 different graphs I need
df.1.1 <- df.1[7:18,]
df.1.2 <- df.1[1:6,]
ggplot(data = df.1.1, aes(x = Month, y = value)) +
geom_bar(aes(fill = variable), position = position_dodge(),stat = 'identity') +
geom_line(data = df.1.2, aes(x=Month, y=value, group=1), size =1.25, color = "#380B61") +
theme(axis.title.x=element_blank(), axis.title.y = element_blank(), legend.position="bottom", legend.direction="horizontal")
Which created this graph: Example Graph
As you can see only the bar chart is showing on the legend. How can I get the line part (Total_1) to also show on the legend as well?
EDIT: To be clear I want the finished chart to look as close to this as possible: Example Graph