Graphics Device for Bitmap Files via Ghostscript
bitmap generates a graphics file.
dev2bitmap copies the current graphics device to a file in a
bitmap(file, type = "png16m", height = 7, width = 7, res = 72, units = "in", pointsize, taa = NA, gaa = NA, …)
dev2bitmap(file, type = "png16m", height = 7, width = 7, res = 72, units = "in", pointsize, …, method = c("postscript", "pdf"), taa = NA, gaa = NA)
The output file name, with an appropriate extension.
The type of bitmap.
- width, height
Dimensions of the display region.
Resolution, in dots per inch.
The units in which
widthare given. Can be
The pointsize to be used for text: defaults to something reasonable given the width and height
- taa, gaa
Number of bits of antialiasing for text and for graphics respectively. Usually 4 (for best effect) or 2. Not supported on all types.
dev2bitmap works by copying the current device to a
bitmap works in the same way using a
and post-processing the output as ‘printing’.
You will need
ghostscript: the full path to the executable can
be set by the environment variable
R_GSCMD. If this is unset, a
GhostScript executable will be looked for by name on your path: on a
"gs" is used, and on Windows the setting of the
GSC is used, otherwise commands
"gswin32c.exe" are tried.
The types available will depend on the version of
but are likely to include
The default type,
"png16m", supports 24-bit colour and
"png256" uses a palette of 256 colours and
could give a more compact representation. Monochrome graphs can use
"pnggray" if anti-aliasing is desired.
Plots with a transparent background and varying degrees of
transparency should use
Note that for a colour TIFF image you probably want
which is 8-bit per channel RGB (the most common TIFF format). None of
the listed TIFF types support transparency.
8-bit per channel CMYK, which printers might require.
For formats which contain a single image, a file specification like
Rplots%03d.png can be used: this is interpreted by Ghostscript.
dev2bitmap if just one of
specified, the other is chosen to preserve the aspect ratio of the
device being copied. The main reason to prefer
method = "pdf"
over the default would be to allow semi-transparent colours to be used.
For graphics parameters such as
"cra" that need to work in
pixels, the default resolution of 72dpi is always used.
On Windows only,
R_GSCMD which contain spaces are
mapped to short names via
bitmap will leave a temporary file (with file name
type = "pdfwrite" will work for simple plots, it
is not recommended. Either use
ps2pdf -dAutoRotatePages=/None on the
postscript: that command is optimized to do
the conversion to PDF in ways that these functions are not.
This section describes the implementation of the conventions for
graphics devices set out in the “R Internals Manual”. These
devices follow the underlying device, so when viewed at the stated
The default device size is 7 inches square.
Font sizes are in big points.
The default font family is (for the standard Ghostscript setup) URW Nimbus Sans.
Line widths are as a multiple of 1/96 inch, with no minimum.
Circle of any radius are allowed.
Colours are interpreted by the viewing/printing application.
savePlot, which for
X11(type = "cairo") provides a simple way to record a PNG
record of the current plot.
To display an array of data, see