R: layout saving as png -
R: layout saving as png -
i have 4 charts (type: ggplot2)and trying save them png. when run code below ch4 gets saved.
png(filename = fname, width = 900, height = 600, units = 'px') layout(matrix(c(1,2,3,4), 2, 2, byrow = true)) ch1 ch2 ch3 ch4 dev.off() i grateful know doing wrong.
ggplot2 graphs can layed out on single page using grid.arrange() gridextra package, e.g.:
df <- data.frame(x=1:3, y=c(1, 4, 9)) p <- ggplot(df, aes(x, y)) p1 <- p + geom_point(colour="red") p2 <- p + geom_point(colour="blue") p3 <- p + geom_point(colour="green") p4 <- p + geom_point(colour="purple") library(gridextra) png(filename="test.png", width=600, height=600) grid.arrange(p1, p2, p3, p4) dev.off() r
Comments
Post a Comment