[R] How to print the graphs in landscape/portrait orientation (revised)

jpm miao miaojpm at gmail.com
Sun Apr 10 02:20:23 CEST 2016


Hi,



      I made a few graphs by ggplot. The following codes produce a pdf file
with graphs, sometimes in landscape orientation, sometimes in portrait
orientation.  I am using both Mac and Windows PC.



    Question: how can I control the orientation of the pdf file? I try to
add a line pdf(paper = “USr”) (or pdf(paper="letter")) in the following
code, but it does not work.



   Thanks!!



#################

library(ggplot2)

library(grid)

library(gridExtra)    # Output graphs to files

n<-100

p2<-array(list(NA),dim=n)

# pdf(paper = "Usr")

# pdf(paper = "letter")

for(i in 1:n)

{

  p2[i][[1]]<-ggplot(data.frame(x=1:(i+1), y=seq(2,2*(i+1),2)), aes(x=x,
y=y))+ geom_line(color="blue")

}

m2 <- marrangeGrob(p2, nrow=3, ncol=2)

ggsave("test_160409xyz.pdf", m2)

##################

	[[alternative HTML version deleted]]



More information about the R-help mailing list