Hello,
I need to plot 3 bars and one line in one graph. I thought It was simple, but I can't progress.
This is the code I've made as an example:
d1=c(rep("in1",13),rep("in2",13),rep("in3",13),rep("in4",13))
value1=data.frame(seq(1:13),runif(n = 13,10,70))
value2=data.frame(seq(1:13),runif(n = 13,0,10))
value3=data.frame(seq(1:13),runif(n = 13,5,75))
value4=data.frame(seq(1:13),runif(n = 13,7,65))
colnames(value1)=c("date","income")
colnames(value2)=c("date","income")
colnames(value3)=c("date","income")
colnames(value4)=c("date","income")
dataF=rbind(value1,value2,value3,value4)
dataT=data.frame(dataF,d1)
library(ggplot2)
p=ggplot(dataT[1:39,],aes(x=date,y=income,fill=d1))
p+geom_col()
p+geom_line(dataT[40:52,],group=1,mapping=aes(x=date,y=income) )
My idea is using geom_col with geom_line on the same graph.
I can plot
p=ggplot(dataT[1:39,],aes(x=date,y=income,fill=d1))
p+geom_col()
or
p=ggplot(dataT[1:39,],aes(x=date,y=income,fill=d1))
p+geom_line(dataT[40:52,],group=1,mapping=aes(x=date,y=income) )
But if my desire is to overlapping them...I fail.
Can you guide me, please?
Thanks for your time and interest.