Skip to content
Prev 79604 / 398502 Next

Basic: setting resolution and size of an R graphic

If you specifically need the plot to have a dimension measured in
pixels, then you need to use a bitmapped format such as png and specify
the output to be the size you require:

  png("test.png", width = 300, height = 300, ...)
  DoYourPlotHere()
  dev.off()

Do this directly using the png() device, rather than trying to convert
the image format, which almost always introduces "noise".

Since you are using a bitmapped format, you will experience the tradeoff
with respect to the image quality (ie. pixelated) as compared to a
vector based format such as PDF or PS.

I would re-verify the requirements for the journal to which you are
submitting the article relative to what they need for image specs. It
seems unusual for a journal to request an image in this fashion, unless
it is a photograph where a jpg format may be preferred or perhaps for
online publication on a web page.

HTH,

Marc Schwartz
On Tue, 2005-10-25 at 08:57 +0200, Dr. med. Peter Robinson wrote: