0

Is there any way to plot multiple graphics using ggplots2 for the graphics that are built in sequence but other scripts are invoked in between? grid.arrange is practical but requires all plots to be defined. the solution given in the discussion

Combined plot of ggplot2 (Not in a single Plot), using par() or layout() function?

can be used but requires to know the sequence or column of the graphics

print(plot1, vp = vplayout(1, 1))

how is it possible like par() to open the device with the number of graphics to plot and like any function such as plot, plot the graphics without knowing in which position or column we're going to plot?

Hope it's clear.

Carol

Community
  • 1
  • 1
carol
  • 153
  • 1
  • 4
  • 17
  • you can look at https://github.com/wilkelab/cowplot `plot_grid()` – zach Jul 24 '15 at 15:42
  • plot_grid also requires to have all plots defined at the time plot_grid is called. I want some thing like the following: in 1 function: `par(mfrow = c(1,5))` in another function: `plot(p1) # will be the 1st plot at left` in 3rd function: `plot(p2) # will be the 2nd plot from left` etc So I just know that I have 5 plots at the beginning but I don't need to pass the order of appearance or position of the plot on the device and I plot them one after the other totally independently and between plotting them other functions are invoked – carol Jul 24 '15 at 18:38
  • this requirement is a little confusing. won't you need to generate the plots at some point? in this case you can pass all of the plots together. But if you want to explore the plot's format, why do you need to put them on the page together? wouldn't it be easier to make them individually? If you are making a multiple panel figure and want to update the panel you can generate each panel with a function and combine them with something like gridExtra or cowplot. However, I don't know of anything that can update subplots in the manner you describe. – zach Jul 24 '15 at 20:45
  • I just wondered if they could be plotted without knowing the order or col position in the same way as we do with par. This still requires to know p1, ..., p3 before calling grid.arrange which I don't have all at the same time. another question is that how to place the title of multiple plots on the top middle of the multiple plot? I know that I should use grid.text but don't know how to place on the top middle. For ex, if I have 5 plots in a row, how to place the title on the 3rd plot? – carol Jul 25 '15 at 08:27

0 Answers0