plotdiff: Test for identical output from 'grid.echo()'

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Functions to generate a scene using the graphics package, reproduce the scene using grid.echo(), test whether the two results are identical, and report on any differences.

Usage

1
2
3
4
plotdiff(expr, label, dev = "pdf",
         antialias = TRUE, density = 100, width = 7, height = 7)
plotdiffInit()
plotdiffResult(warn = FALSE)

Arguments

expr

An expression that draws something using the graphics package.

label

A character value that is used to label files generated during testing.

dev

The graphics device used for drawing and echoing. Currently can only be either "pdf" or "png".

antialias

A logical value indicating whether to perform antialiasing when converting from PDF to PNG.

density

A numeric value indicating the resolution (dpi) to use when converting from PDF to PNG.

width, height

Numeric values indicating the size of the device to test on.

warn

A logical value indicating whether non-identical output should produce a warning or an error.

Details

In default usage, plotdiff() is used to generate two PDF files, one using the original expression and the other from a call to grid.echo(). The PDF files are then converted to PNG files and the PNG files are compared (using ImageMagick). If there are any differences, the comparison generates a further PNG file that shows the differences.

All files are currently generated in the current working directory.

Text messages are also generated by plotdiff() whenever a difference is found, but those messages are stored up rather than printed immediately. The plotdiffResult() function prints out all messages since the last call to plotdiffInit().

Standard usage involves calling plotdiffInit(), followed by one or more plotdiff() calls, then finally a call to plotdiffResult(). Examples of the usage of these functions are provided in the numerous test scripts in the test-scripts directory of the package.

Value

All functions are run for their side effects. In the case of plotdiff(), the generation of PDF and PNG files and the accumulation of differences about messages. In the case of plotdiffResult(), a print out of the accumulated messages, plus possibly either an error or warning.

Author(s)

Paul Murrell

See Also

grid.echo

Examples

1
2
3
4
## Not run: 
plotdiff(expression(plot(1)), "plot")

## End(Not run)

gridGraphics documentation built on Dec. 15, 2020, 5:10 p.m.