Cairo

0th

Percentile

Create a new Cairo-based graphics device

Cairo initializes a new graphics device that uses the Cairo graphics library for rendering. The current implementation produces high-quality PNG, JPEG, TIFF bitmap files, high resolution PDF files with embedded fonts, SVG graphics and PostScript files. It also provides X11 and Windows interactive graphics devices. Unlike other devices it supports all graphics features including alpha blending, anti-aliasing etc.

CairoX11, CairoPNG, CairoPDF, CairoPS and CairoSVG are convenience wrappers of Cairo that take the same arguments as the corresponding device it replaces such as X11, png, pdf, etc.

Keywords
device
Usage
Cairo(width = 640, height = 480, file="", type="png", pointsize=12, 
      bg = "transparent", canvas = "white", units = "px", dpi = "auto",
      ...)

CairoX11(display=Sys.getenv("DISPLAY"), width = 7, height = 7, pointsize = 12, gamma = getOption("gamma"), bg = "transparent", canvas = "white", xpos = NA, ypos = NA) CairoPNG(filename = "Rplot%03d.png", width = 480, height = 480, pointsize = 12, bg = "white", res = NA, ...) CairoJPEG(filename = "Rplot%03d.jpeg", width = 480, height = 480, pointsize = 12, quality = 75, bg = "white", res = NA, ...) CairoTIFF(filename = "Rplot%03d.tiff", width = 480, height = 480, pointsize = 12, bg = "white", res = NA, ...) CairoPDF(file = ifelse(onefile, "Rplots.pdf","Rplot%03d.pdf"), width = 6, height = 6, onefile = TRUE, family = "Helvetica", title = "R Graphics Output", fonts = NULL, version = "1.1", paper = "special", encoding, bg, fg, pointsize, pagecentre) CairoWin(width = 7, height = 7, pointsize = 12, record = getOption("graphics.record"), rescale = c("R", "fit", "fixed"), xpinch, ypinch, bg = "transparent", canvas = "white", gamma = getOption("gamma"), xpos = NA, ypos = NA, buffered = getOption("windowsBuffered"), restoreConsole = FALSE) CairoPS(file = ifelse(onefile, "Rplots.ps", "Rplot%03d.ps"), onefile = TRUE, family, title = "R Graphics Output", fonts = NULL, encoding, bg, fg, width, height, horizontal, pointsize, paper, pagecentre, print.it, command, colormodel)

Arguments
width
width of the plot area (also see units).
height
height of the plot area (also see units).
file
name of the file to be created or connection to write to. Only PDF, PS and PNG types support connections. For X11 type file specifies the display name. If NULL or "" a reasonable default will be chose wh
type
output type. This version of Cario supports "png", a 24 bit RGB image, and "png24", 24 bit RGB with 8 bit Alpha channel, "jpeg", "tiff" 24-bit bitmaps, "pdf" PDF-file with embedded fonts, "svg" SVG-file, "ps" PostScript-file, "x11" X11 intera
pointsize
initial text size (in points).
canvas
canvas color (must be opaque). The canvas is only used by devices that display graphics on a screen and the canvas is only visible only if bg is transparent.
bg
plot background color (can include alpha-component).
units
units for of the width and height specifications. In can be any of "px" (pixels), "in" (inches), "pt" (points), "cm" (centimeters) or "mm"
dpi
DPI used for the conversion of units to pixels. If set to "auto" the DPI resolution will be determined by the back-end.
...
additional backend specific parameters. All parameters listed below are defined by the other devices are are used by the wrappers to make it easier replace other devices by Cairo. They are described in detail in the
display
X11 display, see X11
gamma
gamma correction
xpos
see X11
ypos
see X11
filename
same as file in Cairo
res
see png, will be mapped to dpi for Cairo
quality
quality of the jpeg, see jpeg
onefile
logical: if true (the default) allow multiple figures in one file (see pdf). false is currently not supported by vector devices
family
font family, see pdf
title
see pdf (ignored)
fonts
see pdf, ignored, Cairo automatically detects and embeds fonts
version
PDF version, see pdf (ignored)
paper
see pdf (ignored, Cairo uses device dimensions)
encoding
see pdf (ignored, Cairo uses native enconding except for symbols)
fg
see pdf (ignored)
pagecentre
see pdf (ignored, Cairo uses device dimensions and thus it is irrelevant)
record
see windows (ignored)
rescale
see widnows (ignored)
xpinch
see windows (ignored)
ypinch
see windows (ignored)
buffered
see windows (ignored, Cairo always uses cache buffer)
restoreConsole
see windows (ignored)
record
Windows-specific, ignored on unix
rescale
Windows-specific, ignored on unix
xpinch
Windows-specific, ignored on unix
ypinch
Windows-specific, ignored on unix
buffered
Windows-specific, ignored on unix
restoreConsole
Windows-specific, ignored on unix
horizontal
see postscript (ignored)
print.it
see postscript (ignored)
command
see postscript (ignored)
colormodel
see postscript (ignored, Cairo always uses RGB or ARGB)
Value

  • The (invisible) return value is NULL if the device couldn't be created or a Cairo object if successful. The vaule of the object is the device number.

Known issues

  • The X11 backend is quite slow. The reason is the cairographics implementation of the backend, so we can't do much about it. It should be possible to drop cairographics' Xlib backend entirely and use image backend copied into an X11 window instead. We may try that in future releases.
  • TrueType (and OpenType) fonts are supported when this package is compiled against a cairo graphics library configured with FreeType and Fontconfig support. Therefore make sure have a cairo grpahics library with all bell and whistles to get a good result.
  • R math symbols are supported, but require a TrueType "Symbol" font accessible to Cairo under that name.

See Also

CairoFonts

Aliases
  • Cairo
  • CairoX11
  • CairoPNG
  • CairoPDF
  • CairoSVG
  • CairoPS
  • CairoWin
  • CairoJPEG
  • CairoTIFF
Examples
Cairo(800, 600, file="plot.png", type="png")
plot(rnorm(100),rnorm(100),col=2)
dev.off() # creates a file "plot.png" with the above plot
Documentation reproduced from package Cairo, version 1.3-2, License: GPL version 2

Community examples

Looks like there are no examples yet.