I'm using egg::arrange
to setup multiple plots and while it is sizing the x-axis correctly for both plots the x-axis values are not aligned. Easier to explain with an example:
data <- data.frame(
volume=c(100,200,150,400),
revenue=c(1000,2500,1750,6000),
day=c(as.Date('2019-10-01'),as.Date('2019-10-02'),as.Date('2019-10-03'),as.Date('2019-10-04'))
)
p1 <- ggplot(data, aes(x=day,y=volume)) + geom_line()
p2 <- ggplot(data, aes(x=day,y=revenue)) + geom_col()
egg::ggarrange(p1,p2,nrow=2,heights=c(3,1))
The desired output would be each individual day is aligned between plots. Extra nice would be removing the x-axis entirely from the first plot.
Ideally this would compose with other egg::ggarrange
as I'm actually combining a bunch of plots.
Thanks!