[R-sig-eco] Publication quality graphics in R

Glen A Sargeant gsargeant at usgs.gov
Fri May 30 23:55:04 CEST 2008


You can exert quite a lot of control over the appearance of JPG output. 
Try inserting "lowres.jpg" and "hires.jpg" (generated by the code below) 
into a Word document and comparing the results.

foo <- function(){
plot.new()
plot.window(c(0,1),c(0,1))
plot(sin(seq(0,2*pi,0.01)),type="l",col="blue",lwd=2)
title("Example")}

jpeg("lowres.jpg",width=480,height=480)
foo()
dev.off()

jpeg("hires.jpg",width=4*480,height=4*480,pointsize=48)
foo()
dev.off()

*************************************************
Glen A. Sargeant, Ph.D.
Research Wildlife Biologist/Statistician
Northern Prairie Wildlife Research Center
8711 37th Street SE
Jamestown, ND  58401

Phone: (701) 253-5528
E-mail:  glen_sargeant at usgs.gov
FAX:     (701) 253-5553
*************************************************



David Hewitt <dhewitt37 at gmail.com> 
Sent by: r-sig-ecology-bounces at r-project.org
05/30/2008 04:06 PM

To
r-sig-ecology at r-project.org
cc

Subject
Re: [R-sig-eco] Publication quality graphics in R









> I'd like to hear from the list, how folks specify and export 
presentation
> quality and publication quality graphics with R.  I've had problems 
> when exporting graphics using the copy-to-clipboard option (both bitmap
> and metafile) 
> and also when saving them as jpgs.  They almost always seem to look a
> little funny 
> (e.g. pixelation, symbols coming out distorted etc.).  The only option
> that I've had 
> much success with is saving them as pdf's, but that format is less than
> ideal when trying 
> to incorporate a graphic into another document (e.g. Word or 
Powerpoint),
> and is often 
> not the format requested by journals.
> 

I'd strongly recommend making the figures by writing them to files rather
than copying and pasting from the graphics device window. So, for example,
when you want a figure as a pdf you'd use "pdf(filename, options)" to open
the device with the output settings you desire, then do all your plotting
commands, then close the device with dev.off().

type ?pdf at the prompt; other devices are described in ?png

You can run the plots in the device window and then save as..., but you'll
get subtle (and sometimes not-so-subtle) differences between the window
display and the output through a device command. Once you get what you 
like,
then fine-tune the device options to produce the final file to be imported
to your text.

The format you use will vary depending on what you're putting it into. 
I've
had the most luck with PDF images rolled into LaTeX PDFs (via LyX --
www.lyx.org), although I've heard that EPS is even better for some things.
JPGs never worked well for me in anything. I gave up on M$ Office a few
years ago. Not much looks good in there.


-----
David Hewitt
Research Fishery Biologist
USGS Klamath Falls Field Station (USA)
-- 
View this message in context: 
http://www.nabble.com/Publication-quality-graphics-in-R-tp17567736p17567948.html

Sent from the r-sig-ecology mailing list archive at Nabble.com.

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology



More information about the R-sig-ecology mailing list