Search code examples
rggplot2sweaveodfweave

Match ODFWeave and ggplot2 image resolution/size


I'm creating charts using ggplot2 inside ODFWeave code chunks. I am setting the ODFWeave dimensions to 5x5in, but the graphs are being created at 480x480 px which looks like a default. How can I make these larger and match them to the ODF size to get a good quality print?

ODFWeave Options:

imageDefs <- getImageDefs()
imageDefs$dispWidth <- 5
imageDefs$dispHeight<- 5
setImageDefs(imageDefs)

Code snippet in weave doc:

<<ClosureGraph, echo = FALSE, fig = TRUE>>= 
   #function returns a ggplot obj.
   p<-closuresbyperiod() 
   print(p)
@

Solution

  • Thanks to the package manager for pointing out that we can use plotWidth and Height to do this, e.g:

    imageDefs <- getImageDefs()
    imageDefs$dispWidth <- 4
    imageDefs$dispHeight<- 4
    imageDefs$plotWidth <- 800
    imageDefs$plotHeight<- 800
    setImageDefs(imageDefs)
    

    This is done before issues the odfWeave command