Hello,
I would like to plot in the same graph two dataset below with ggplot 2.
I can draw independent graph with ggplot but, how can I put them on the same graph with ggplot?
Do you have an idea?
The unit of the variable p is percent.
You will find below what I have done...
Thanks in advance to your help!
rm(list = ls())
library(dplyr)
#>
#> Attachement du package : 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(tidyverse)
df<-data.frame(
Time=as.Date(c("2020/01/01", "2020/02/01", "2020/03/01")),
Qte_total=as.numeric(c("780","803","819")),
Qte_total_prio=as.numeric(c("10","23","30")),
Qte_ouverture = as.numeric(c("20","40","5")),
Qte_sortie=as.numeric(c("2","4","10"))
)
p<-data.frame(Time=as.Date(c("2020/01/01", "2020/02/01", "2020/03/01")),
OTD=as.numeric(c("0.1","0.3","0.2")))
df.l<-df %>%gather("types", "qte", -Time)
ggplot(df.l, aes(x=Time , y=qte,fill=types)) +
geom_bar(position="dodge", stat="identity")
ggplot(p,aes(x=Time,y=OTD))+
geom_line()