Thank you for the help, @Z3tt! these are great examples.
I see that putting position = "dodge2" works when you group data.
Data I am working with has 2 columns and I create 2 geom_col to ggplot().
My example:
library(data.table)
library(ggplot2)
DF <- data.table(Fiscal_Year = seq(2001, 2019, by =1))
DF <- DF[,var1 := data.table(rnorm(19, 30, 5))]
DF <- DF[,var2 := data.table(rnorm(19, 60, 10))]
DF <- data.frame(DF)
ggplot() +
geom_col(data=DF, mapping = aes(x=Fiscal_Year, y=var2,group = 1, fill = "orangered1"),
color = "black", position = "dodge2")+
geom_col(data=DF, aes(x=Fiscal_Year, y=var1,group = 2, fill = "royalblue3"),
color = "black", position = "dodge2")+
theme_bw()`DF <- data.table(Fiscal_Year = seq(2001, 2019, by =1))
DF <- DF[,var1 := data.table(rnorm(19, 30, 5))]
DF <- DF[,var2 := data.table(rnorm(19, 60, 10))]
DF <- data.frame(DF)
ggplot() +
geom_col(data=DF, mapping = aes(x=Fiscal_Year, y=var2,group = 1, fill = "orangered1"),
color = "black", position = "dodge2")+
geom_col(data=DF, aes(x=Fiscal_Year, y=var1,group = 2, fill = "royalblue3"),
color = "black", position = "dodge2")+
theme_bw()`
