[R] resolution (dpi) problem

Marc Schwartz marc_schwartz at comcast.net
Sun Apr 27 18:14:52 CEST 2008

Prof Brian Ripley wrote:
> On Sat, 26 Apr 2008, Marc Schwartz wrote:
>> See comments inline:
>> Chris Walker wrote:
>>> I am using R 2.4.1 with Windows XP.
>> First, you are using a version of R that is a year and a half and 6
>> releases out of date.  Version 2.7.0 was just released this past week.
>> You can download it from your nearest CRAN mirror.
>>> I use the plot command in a fairly simple script and I use the right 
>>> mouse
>>> click on the plot and save as a postscript file. I used the resultant 
>>> file
>>> in a paper which was submitted electronically. However, I get the 
>>> following
>>> response from the journal:
>>> Your manuscript has been unsubmitted because you failed to meet the
>>> submission guidelines as indicated below:
>>> -Your figures must be submitted in TIFF or EPS format according to the
>>> following minimum resolutions:
>>> 1200 dpi for black and white line art (simple bar graphs, charts, etc.)
>>> 300dpi for halftones (black and white photographs) 600dpi for 
>>> combination
>>> halftones (Photographs that also contain line art such as labeling or 
>>> thin
>>> lines)
>>> Does anyone know how to produce the correct settings for the journal 
>>> (i.e.
>>> 1200 dpi)?
>> Their comments about resolution apply to TIFF files and not EPS files,
>> which are resolution independent.
>> It has been several years since I last used the Windows version of R,
>> but if the 'File Save As' menu for the plot indicates Postscript and not
>> Encapsulated Postscript, that is your problem.
> Whatever the menu says, it does produce Encapsulated PostScript (which 
> is a special case of PostScript)
> R's postscript is always encapsulated, but EPS also requires a single 
> frame and a suitable header.  If you save from the menu it is
> %!PS-Adobe-3.0 EPSF-3.0
> ...

OK. For my own edumacation, I installed the Windows version of R:

   R version 2.7.0 Patched (2008-04-26 r45507)

under Wine on F8, where it runs quite well.

I then created a basic barplot:


and saved it to 'Menu.eps' using the "Save as postscript" menu.

I then created the same plot, using postscript() to create an EPS file:

    postscript("EPS.eps", height = 7, width = 7, onefile = FALSE,
               paper = "special", horizontal = FALSE)



Doing a diff on the two files shows that the key difference between the 
two is the bounding box:

$ diff Menu.eps EPS.eps
< %%BoundingBox: 54 144 558 648
 > %%BoundingBox: 0 0 504 504

Of course, all other coordinates are relative to the two differing origins.

There are other encoding differences which are to be expected.

To Prof. Ripley's comment, the EPS header is the same:

   %!PS-Adobe-3.0 EPSF-3.0

So it would appear that perhaps it is the bounding box dimensions not 
being adjusted to a 0,0 origin that are probably throwing things off 
here for your publisher.

>> You can use dev.copy2eps(...) after you have plotted the graphic to the
>> screen device, or better, plot directly to an EPS file by surrounding
>> your plot code with:
>>   postscript("FileName.eps", width = X, height = Y, paper = "special",
>>              horizontal = FALSE, onepage = FALSE)

BTW, I noted that I had a brain fart here and that the 'onepage' above 
should be 'onefile' as I used above.

>>   dev.off()
>> See ?dev.copy and/or ?postscript for more help.
>> And...be sure to install the latest version of R.  :-)
> Not least because it can produce a 1200dpi TIFF figure via the tiff() 
> device.

Good point.



More information about the R-help mailing list