library(ggplot2)# Create first plot and assign it to variablep1 = qplot(wt, mpg, data = mtcars, xlab = 'Car weight', ylab = 'Mileage')# Create second plot and assign it to variablep2 = qplot(wt, mpg, color = factor(cyl), data = mtcars, geom = c('point', 'smooth'), xlab = 'Car weight', ylab = 'Mileage')# Define grid layout to locate plots and print each graphpushViewport(viewport(layout = grid.layout(1, 2)))print(p1, vp = viewport(layout.pos.row = 1, layout.pos.col = 1))print(p2, vp = viewport(layout.pos.row = 1, layout.pos.col = 2))
没有评论:
发表评论