How can I save grid.arrange() plot to file ?

0 votes
May 16, 2018 in Data Analytics by shams
• 3,580 points
1,067 views

1 answer to this question.

0 votes
grid.arrange() directly draws on our device.
However, arrangeGrob doesn't draw anything but returns a grob g, which can be passed to ggsave(file="something.pdf", g).

 # draw your plots
 p1 <- ggplot(...) # first plot
 p2 <- ggplot(...) # second plot
 p3 <- ggplot(...) # third plot

 #merge all plots within one grid
 grid.arrange(p1, p2, p3, nrow=3) #arranges plots within grid

 #save
 g <- arrangeGrob(p1, p2, p3, nrow=3) #generates g
 ggsave(file="something.pdf", g) #saves g
answered May 16, 2018 by zombie
• 3,690 points

Related Questions In Data Analytics

0 votes
1 answer

How can I import a file in R without giving the destination/file path to the specified file?

You can use the window explorer to ...READ MORE

answered Aug 28, 2018 in Data Analytics by Anmol
• 3,620 points

edited Aug 28, 2018 by Vardhan 33 views
0 votes
1 answer

How can I use R to list all files with a specified extension ?

fls <- list.files(pattern = "\\.dbf$") $ at the ...READ MORE

answered May 10, 2018 in Data Analytics by zombie
• 3,690 points
16 views
0 votes
1 answer

How can I find file name from full file path in R?

You can use: basename("C:/some_dir/filename.ext") # [1] "filename.e ...READ MORE

answered May 24, 2018 in Data Analytics by zombie
• 3,690 points
15 views
0 votes
1 answer

How can I read a .csv file in R language?

read.csv () function is used to read ...READ MORE

answered Jun 11, 2018 in Data Analytics by zombie
• 3,690 points
26 views
0 votes
1 answer

How can I convert a factor variable to numeric in R ?

A factor variable can be converted to ...READ MORE

answered Sep 18, 2018 in Data Analytics by shams
• 3,580 points
30 views
0 votes
1 answer

How can I convert a list to a dataframe?

L = ['1', '2','3','4','5'] #create new df df ...READ MORE

answered Sep 18, 2018 in Data Analytics by Anmol
• 3,620 points
18 views
0 votes
1 answer
0 votes
1 answer

Error saying cannot open file 'file.pdf' when trying to save a plot in ggplot

You could try adding the following line ...READ MORE

answered Nov 9, 2018 in Data Analytics by Maverick
• 10,040 points
308 views
0 votes
1 answer

How can I remove plot axis values?

In order to remove numbering on x-axis ...READ MORE

answered May 7, 2018 in Data Analytics by zombie
• 3,690 points
12 views
0 votes
1 answer

How can I append rows to an R data frame?

Consider a dataSet i.e cicar(present under library ...READ MORE

answered May 8, 2018 in Data Analytics by zombie
• 3,690 points
30 views