I would like to add a line to my barplot. This line is built with one of the variable of my dataframe "graphOR"). Here's my data :
graphOR1 <- structure(list(STYear_name = structure(c(2L, 4L, 5L, 1L, 3L), .Label = c(" Q4-2016",
"Q1-2016", "Q1-2017", "Q2-2016", "Q3-2016"), class = "factor"),
Obj = c(6.13, 6.06, 6.07, 6.07, 6.07), Real = c(7.8, 8.07,
7.71, 7.62, 8.33)), .Names = c("STYear_name", "Obj", "Real"
), row.names = c(NA, -5L), class = "data.frame")
graphOR1
STYear_name Workareabis Obj Real
11 Q1-2016 Overall 6.13 7.80
9 Q2-2016 Overall 6.06 8.07
8 Q3-2016 Overall 6.07 7.71
7 Q4-2016 Overall 6.07 7.62
10 Q1-2017 Overall 6.07 8.33
dput(graphOR1)
structure(list(STYear_name = structure(c(31L, 33L, 34L, 35L,
32L), .Label = c("1-01-2017", "19-12-2016", "2-01-2017", "20-12-2016",
"2015", "2016", "2017", "21-12-2016", "22-12-2016", "23-12-2016",
"24-12-2016", "25-12-2016", "26-12-2016", "27-12-2016", "28-12-2016",
"29-12-2016", "30-12-2016", "31-12-2016", "M01-2017", "M02-2016",
"M03-2016", "M04-2016", "M05-2016", "M06-2016", "M07-2016", "M08-2016",
"M09-2016", "M10-2016", "M11-2016", "M12-2016", "Q1-2016", "Q1-2017",
"Q2-2016", "Q3-2016", "Q4-2016", "W01-2017", "W48-2016", "W49-2016",
"W50-2016", "W51-2016", "W52-2016"), class = "factor"), Workareabis = c("Overall",
"Overall", "Overall", "Overall", "Overall"), Obj = c(6.13, 6.06,
6.07, 6.07, 6.07), Real = c(7.8, 8.07, 7.71, 7.62, 8.33)), .Names = c("STYear_name",
"Workareabis", "Obj", "Real"), class = "data.frame", row.names = c(11L,
9L, 8L, 7L, 10L))
I would like to add to my barplot a line with the variable "Obj". I tried :
ggplot(data = graphOR1, aes(x=STYear_name, y= Real))+geom_bar(stat="identity",aes(fill = Real))+scale_fill_gradient(low="#56B4E9", high="blue")+ggtitle("Plot")
lines(graphOR1$STYear_name,graphOR1$Obj,col="blue")
or
p1 <- ggplot(data = graphOR1, aes(x = STYear_name, y = Real)) + geom_bar(stat = "identity",aes(fill = Real))+scale_fill_gradient(low="#56B4E9", high="blue")+ geom_line(colour = "orange",size=1)
but it isn't working.
Thank you in advance!