Re: [R] Problems outputting ggplot2 graphics to pdf

2017-03-02 Thread Ulrik Stervbo
Hi Hugh, I believe the recommended way of saving ggplots is through ggsave. It defaults to take the latest plot displayed, but you can specify which plot to save by passing the variable to the plot argument. If you need to save multiple plots in one file, you have to create a multipage plot using

Re: [R] Problems outputting ggplot2 graphics to pdf

2017-03-02 Thread Hugh Morgan
Thanks for the help. My test script was changed with: p <- ggplot(df, aes(gp, y)) + geom_point() + geom_point(data = ds, aes(y = mean), colour = 'red', size = 3) print(p) And this now works. Cheers, Hugh On 02/03/17 13:42, Richard M. Heiberger wrote: You need the print() statement. Se

Re: [R] Problems outputting ggplot2 graphics to pdf

2017-03-02 Thread Duncan Murdoch
On 02/03/2017 8:37 AM, Hugh Morgan wrote: Hi All, I am having trouble outputting ggplot2 graphics to pdf as part of a script. It works if when I pipe the script into R or if I type the commands directly into the terminal, but not if I load it using the source(..) command. In this case the outp

Re: [R] Problems outputting ggplot2 graphics to pdf

2017-03-02 Thread Richard M. Heiberger
You need the print() statement. See FAQ 7.22 in file system.file("../../doc/FAQ") 7.22 Why do lattice/trellis graphics not work? == The most likely reason is that you forgot to tell R to display the graph. Lattice functions such as 'xyplot()' create

[R] Problems outputting ggplot2 graphics to pdf

2017-03-02 Thread Hugh Morgan
Hi All, I am having trouble outputting ggplot2 graphics to pdf as part of a script. It works if when I pipe the script into R or if I type the commands directly into the terminal, but not if I load it using the source(..) command. In this case the outputted pdf is always size 3611, and it fails