0

I did a plot in R & I want to define some format issues in my plot but I haven't got it.

  1. Is it possible define the size of plot? How?
  2. I want change the font family for Times New Roman. Is it possible?
  3. How do it export a plot to Word with high quality. I tried with tiff but the plot wasn't good.
hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
user4482513
  • 41
  • 1
  • 1
  • 1

1 Answers1

4

You can use ReporteRs package to export the plot to Word. See the following example - it will produce a .docx file containing an editable graph in a vector graphics format (high quality) with a defined size.

library( ggplot2 )
library( ReporteRs )
doc = docx( )

myplot = qplot(Sepal.Length, Petal.Length, data = iris
  , color = Species, size = Petal.Width, alpha = I(0.7) )

doc = addPlot( doc = doc, fun = print, x = myplot, 
  vector.graphic = T, # vector graphic instruction
  fontname = "Times New Roman",  # font specification
  width = 4, height = 4 #dim. are in inches
  )

writeDoc( doc, file = "test.docx" )
David Gohel
  • 9,180
  • 2
  • 16
  • 34