bmp(filename = "Rplot%03d.bmp",
    width = 480, height = 480, units = "px", pointsize = 12,
    bg = "white", res = NA, …,
    type = c("cairo", "Xlib", "quartz"), antialias)jpeg(filename = "Rplot%03d.jpeg",
     width = 480, height = 480, units = "px", pointsize = 12,
     quality = 75,
     bg = "white", res = NA, …,
     type = c("cairo", "Xlib", "quartz"), antialias)
png(filename = "Rplot%03d.png",
    width = 480, height = 480, units = "px", pointsize = 12,
     bg = "white",  res = NA, …,
    type = c("cairo", "cairo-png", "Xlib", "quartz"), antialias)
tiff(filename = "Rplot%03d.tiff",
     width = 480, height = 480, units = "px", pointsize = 12,
     compression = c("none", "rle", "lzw", "jpeg", "zip", "lzw+p", "zip+p"),
     bg = "white", res = NA,  …,
     type = c("cairo", "Xlib", "quartz"), antialias)
PATH_MAX characters long, and may be truncated if not.
    See postscript for further details.)  Tilde expansion
    is performed where supported by the platform.height and width are
    given.  Can be px (pixels, the default), in (inches),
    cm or mm.res ppi.type = "quartz".units
    other than the default, and to convert points to pixels."Xlib" or "quartz"
    (some macOS builds) or "cairo".  The latter will only be
    available if the system was compiled with support for cairo --
    otherwise "Xlib" will be used.  The default is set by
    getOption("bitmapType") -- the ‘out of the box’
    default is "quartz" or "cairo" where available,
    otherwise "Xlib".type = "cairo", giving the type of
    anti-aliasing (if any) to be used for fonts and lines (but not
    fills). See X11.  The default is set by
    X11.options.  Also for type = "quartz", where
    antialiasing is used unless antialias = "none".width and height values are in
  pixels not inches.  A warning will be issued if both are less than 20. If you plot more than one page on one of these devices and do not
  include something like %d for the sequence number in
  file, the file will contain the last page plotted.fontconfig to support a wide range of
    font formats.  (This was first available on Windows in R 2.14.0.)
  .jpg and .tif on Windows, and
  .jpeg and .tiff elsewhere.res ppi.
    res ppi),
    minimum one pixel for type = "Xlib", 0.01 for type =
      "cairo".
    type = "Xlib" circle radii are in pixels with
    minimum one.
    type = "quartz" see the help for quartz.tiff is lossless and stores RGB (and alpha where
  appropriate) values uncompressed---such files are widely accepted,
  which is their main virtue over PNG. png supports transparent backgrounds: use bg =
  "transparent".  (Not all PNG viewers render files with transparency
  correctly.)  When transparency is in use in the type = "Xlib"
  variant a very light grey is used as the background and so appears as
  transparent if used in the plot. This allows opaque white to be used,
  as in the example.  The type = "cairo", type =
  "cairo-png" and type = "quartz" variants allow
  semi-transparent colours, including on a transparent or
  semi-transparent background. tiff with types "cairo" and "quartz" supports
  semi-transparent colours, including on a transparent or
  semi-transparent background.  Compression type "zip" is
  ‘deflate (Adobe-style)’.  Compression types "lzw+p" and
  "zip+p" use horizontal differencing (‘differencing
  predictor’, section 14 of the TIFF specification) in combination with
  the compression method, which is effective for continuous-tone images,
  especially colour ones. R can be compiled without support for some or all of the types for
  each of these devices: this will be reported if you attempt to use
  them on a system where they are not supported.  For type =
  "Xlib" they may not be usable unless the X11 display is available to
  the owner of the R process.  type = "cairo" requires cairo 1.2
  or later.  type = "quartz" uses the quartz device
  and so is only available where that is (on some macOS builds: see
  capabilities("aqua")). By default no resolution is recorded in the file, except for BMP.
  Viewers will often assume a nominal resolution of 72 ppi when none is
  recorded.  As resolutions in PNG files are recorded in pixels/metre,
  the reported ppi value will be changed slightly. For graphics parameters that make use of dimensions in inches
  (including font sizes in points) the resolution used is res (or
  72 ppi if unset). png will normally use a palette if there are less than 256
  colours on the page, and record a 24-bit RGB file otherwise (or a
  32-bit ARGB file if type = "cairo" and non-opaque colours are
  used).  However, type = "cairo-png" uses cairographics' PNG
  backend which will never use a palette and normally creates a larger
  32-bit ARGB file---this may work better for specialist uses with
  semi-transparent colours. Quartz-produced PNG and TIFF plots with a transparent background are
  recorded with a dark grey matte which will show up in some viewers,
  including Preview on macOS. Prior to R 3.0.3 unknown resolutions in BMP files were sometimes
  recorded incorrectly: they are now recorded as 72 ppi.Devices, dev.print capabilities to see if these devices are
  supported by this build of R, and if type = "cairo" is supported. bitmap provides an alternative way to generate plots in many
  bitmap formats that does not depend on accessing the X11 display but does
  depend on having GhostScript installed.## these examples will work only if the devices are available
## and cairo or an X11 display or a macOS display is available.
## copy current plot to a (large) PNG file
## Not run: dev.print(png, file = "myplot.png", width = 1024, height = 768)
png(file = "myplot.png", bg = "transparent")
plot(1:10)
rect(1, 5, 3, 7, col = "white")
dev.off()
## will make myplot1.jpeg and myplot2.jpeg
jpeg(file = "myplot%d.jpeg")
example(rect)
dev.off()
Run the code above in your browser using DataLab