1

I create a plot with ggplot and save it as an png in my linux box.

When I insert the plot into a presentation in Windows using MS Powerpoint (2013) it all looks fine until I go full screen with F5: in full screen the axes and the grey background grid disappears (font rendering is also noticeably worse).

In the presenter notes it still looks fine.

The png looks perfectly fine, only once projected in full screen on a secondary screen (monitor/wall) it goes bad. Full screen on primary screen works - this doesn't seem to be a resolution issue.

I tried saving plots in two different ways with the same results:

# 1
ggsave(filename="test.png", p)

# 2
png(file = "test.png", width = 1024, height = 768, units = 'px', dpi=300)
print(p)
dev.off()

Specifieng type (cairo-png) doesn't help either.

Workaround: exporting to pdf and displaying that in fullscreen works completely fine. It is only inconvenient if I want to have my notes along.

user673592
  • 2,090
  • 1
  • 22
  • 37
  • Have you tried the recommendations here? http://www.r-bloggers.com/high-resolution-figures-in-r/ – tcash21 Mar 18 '16 at 16:15
  • Make the image bigger (more dpi)? – Roman Luštrik Mar 18 '16 at 16:43
  • you can try to save it as emf file (ggsave("test.emf", p)) or create a PPTX file directly http://davidgohel.github.io/ReporteRs/addPlot.html ... so you have vector images and no bitmaps. – ckluss Mar 18 '16 at 16:57
  • Just added a solution using the new export package, built on top of the officer package to save directly to native Powerpoint format... – Tom Wenseleers Nov 03 '18 at 23:14

2 Answers2

1

You can bring all of these together with

ggsave(filename="test.png",width=1024,height=768,units='px',dpi=300)

You can adjust the dpi to 600, but usually 300 will suffice. I've also had success using inches instead of pixels for ppt instead of pixels.

GregdeLima
  • 404
  • 1
  • 9
  • 27
  • Thanks, I've tried, but it really isn't a resolution issue. After testing more, it is clear that it only happens in full screen on the secondary screen not primary... I have no idea what is the problem... – user673592 Mar 21 '16 at 13:14
1

You can use the new export package to save your ggplot2 graph to native Powerpoint format- that should work OK, see https://cran.r-project.org/web/packages/export/index.html and for demo https://github.com/tomwenseleers/export

Typical syntax is very easy, e.g.:

install.packages("export")
library(export)
library(ggplot2)
qplot(Sepal.Length, Petal.Length, data = iris, color = Species, 
      size = Petal.Width, alpha = I(0.7))     
graph2ppt(file="ggplot2_plot.pptx", width=6, height=5) 

You can also use it to export to Word, Excel, Latex or HTML and you can also use it to export statistical output of various R stats objects.

Tom Wenseleers
  • 7,535
  • 7
  • 63
  • 103