0

I would like to make publication quality (300 dpi) images with R and I have looked at these Preparing publication-quality figures in R with more than one panel and Arrange many plots using gridExtra, but am wondering if there is something out there that is a little more general?

If we are already printing to a device, how can we print the same thing to a high resolution file (preferably tiff)?

When I try to save images as .eps, it seems to work from R's end, but I am never able to open the image anywhere. What I have been doing is printing a to pdf, then opening the pdf in imaging software (gimp), then exportingthe same image as .tiff. However, on recent figures the pdf resolution is not good enough.

It seems that having more than one panel really complicates the question and we all create multiple-panel figures differently (even differently within grid or gridExtra).

So, assuming some one has successfully communicated their image to the regular plotting device, what is the best way to capture the same thing in a high-resolution file?

Not a polished example, but this is the full-page figure I am trying to create:

vplayout<- function(x,y)
   viewport(layout.pos.row=x, layout.pos.col=y)

pdf("CC Calibrations Deluxe.pdf", width = 6.5, height = 9)
grid.newpage()
pushViewport(viewport(layout = grid.layout(8,3, heights = unit(c(2.5, 2.5,      
      2.5,2.5,2.5,2.5,2.5,.5),"null"), widths = unit(c(.5,5,2.5), "null"))))
grid.text((expression(paste("Soil Moisture (mm mm" ^ "-1",")"))), rot = 90, 
      vp = viewport(layout.pos.row = 3:7, layout.pos.col = 1), gp=gpar(fontsize=18))
grid.text((expression(paste("Dry Mass (kg m" ^ "2",")"))), rot = 90,
      vp = viewport(layout.pos.row = 1:2, layout.pos.col = 1), gp=gpar(fontsize=18))
grid.text("Year", vp = viewport(layout.pos.row = 8, layout.pos.col = 1:2), gp=gpar(fontsize=18))
print(cc.bio, vp = vplayout (1,2))
print(cc.yield, vp = vplayout(2,2))
print(cc5sw, vp = vplayout (3,2))
print(cc10sw, vp = vplayout(4,2))
print(cc15sw, vp = vplayout (5,2))
print(cc35sw, vp = vplayout (6,2))
print(cc75sw, vp = vplayout (7,2))
print(comp.bio.cc, vp = vplayout (1,3))
print(comp.yield.cc, vp = vplayout(2,3))
print(comp5.cc, vp = vplayout (3,3))
print(comp10.cc, vp = vplayout(4,3))
print(comp15.cc, vp = vplayout (5,3))
print(comp35.cc, vp = vplayout (6,3))
print(comp75.cc, vp = vplayout (7,3)))
dev.off()

And the result after running it through image software is below. The points are circles and are not empty on the R device (Cairo).

enter image description here

Community
  • 1
  • 1
Nazer
  • 3,654
  • 8
  • 33
  • 47
  • Gave you tried `ggsave`? – Roman Luštrik Sep 10 '14 at 20:12
  • Yes. `ggsave` gives me a file with only the last printed figure. – Nazer Sep 10 '14 at 20:29
  • What about exporting as PDF instead? Then it would be scalable w/o resolution constraints. – beroe Sep 10 '14 at 20:59
  • Yes, @beroe, I always export as a PDF, but even that makes my points look like blobs, even if they are little. I don't know of any publications that accept figures as pdfs. – Nazer Sep 11 '14 at 03:18
  • 1
    Strange about the PDF blobs. Are you generating it by creating a device `pdf("myfigure.pdf")` followed by your plot commands, followed by `dev.off()`? If you just do `Save As...` it does not give equal results. Also in my experience (~70 publications) every journal has taken PDF or at least EPS. Sometimes it requires a little arm-twisting with the editor, but the actual layout and graphics people know how to use the files properly. – beroe Sep 11 '14 at 04:54
  • Oh, I see you are doing the `pdf` method... (I read the question not your code!) Inkscape [should be able](http://clownfishcafe.blogspot.com/2014/05/importing-eps-files-into-inkscape.html) to import your EPS..? – beroe Sep 11 '14 at 04:55

0 Answers0