makeFigure: Open a device to plot a figure

Description Usage Arguments Details Value Author(s) Examples

Description

Open a device to plot a figure

Usage

1
2
makeFigure(file, kind='pdf', device=getOption('device'), type='Xlib', imtype='cairo', width=7, height=7, units='in',
res=300, quality=95...)

Arguments

file

filename for figure when run in non-interactive mode. If no filename is given for a non-interactive mode call, pdf files are named Rplot.pdf, while png files are named Rplot-%03d.png

kind

the desired kind of plot. Supports one of 'pdf', 'png', 'jpeg', or 'tiff'

device

the desired device, when run in interactive mode. This can be either 'quartz' or 'x11'. Uses whatever is set as the default if left empty.

type

the type of device, for x11 devices, when run in interactive mode. This can be 'Xlib', 'cairo', etc. See ?x11

imtype

the type of device to use when writing to an image file (png and jpeg). Defaults to 'cairo' because of the antialiasing lines on filled contour plots when using 'quartz'

width, height

desired width and height of the figure

units

units to use for the figure. kind='pdf' defaults to inches, and this is usually the norm to make png files look the same, and so is the default

res

resolution to use for the png

quality

jpeg quality percentage to use; defaults to 95

...

other device options, including options specific to particular devices

Details

This function is just a shortcut for making figures in a consistent way, to avoid copying and pasting code chunks. It will produce an on-screen figure when run in interactive mode (of default type x11). When run from the command line (e.g. using R --no-save < script.R), it will produce a graphics file of the specified kind.

kind='jpeg' uses a default quality of 95.

Note that for the file creation to function properly in non-interactive mode, the function call must be accompanied by:

if (!interactive()) dev.off() or by closeFigure()

to turn the graphics device off.

Value

none.

Author(s)

Clark Richards

Examples

1
2
3
makeFigure('test', kind='pdf', height=3)
plot(rnorm(100), rnorm(100))
closeFigure()

richardsc/crMisc documentation built on May 27, 2019, 7:59 a.m.