asCairoDevice {cairoDevice}R Documentation

Converting GTK+ widgets to Cairo graphics devices

Description

Allows one to convert an arbitrary realized GTK+ widget (usually a GtkDrawingArea) or a GdkDrawable (like a GdkPixmap) to a Cairo graphics device, so that R plot commands draw to the widget/drawable.

Usage

asCairoDevice(widget, pointsize = 10)

Arguments

widget The realized widget or drawable to which the R graphics are drawn
pointsize The default font size in the R plot

Details

The main purpose of this function is to allow the user to embed an R plot in a GTK user interface constructed with RGtk2. Please see the examples in the RGtk2 package.

Drawing to an offscreen GdkPixmap is useful for buffering and transforming R graphics. For example, one could copy the pixmap to a GdkPixbuf and add a watermark before saving as a gif, png, jpg, etc.

Note

In previous versions of the package (pre 2.0), it was possible to call asCairoDevice on a widget before it was realized. This should not have been allowed, because it is impossible to draw to an unrealized widget. Many published examples called asCairoDevice before realizing the widget, but they will now fail with an error. When calling asCairoDevice on a widget, first realize the widget, for example by adding the widget to a container where the top-level ancestor is visible.

Author(s)

Michael Lawrence

References

http://www.ggobi.org/rgtk2 http://www.gtk.org/ http://www.cairographics.org/


[Package cairoDevice version 2.8 Index]