I have three plots saved to ET1, ET2, and ET3 where each plots different y-axis values but all have the same x-axis values. The y-axis labels are different lengths, so the vertical lines for the x-axis dates do not line up when saving as a .png
png(filename="C:/plotting/3_part_data/ET.png", width=650, height=850, units="px", res=100)
grid.arrange(ET1,ET2,ET3,ncol=1,nrow=3)
dev.off()
Current result of the plots; you can see where the three vertical lines don't align.
Since there are no elements that change size on the right of any of the plots, I was wondering if there is a way to align them on the right side when saving as .png?
Thanks for pointing towards the other question; this is what worked for me:
library(gtable)
# Start png
png(filename="C:/G.png", width=650, height=850, units="px", res=100)
# Get the ggplot grobs
gA <- ggplotGrob(ET1)
gB <- ggplotGrob(ET2)
gC <- ggplotGrob(ET3)
# Combine the plots
g = cbind.gtable(rbind.gtable(gA, gB, gC, size = "max"), size = "max")
# Draw it
grid.draw(g)