grid.echo()
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.
plotdiff(expr, label, dev = "pdf",
antialias = TRUE, density = 100, width = 7, height = 7)
plotdiffInit()
plotdiffResult(warn = FALSE)
An expression that draws something using the graphics package.
A character value that is used to label files generated during testing.
The graphics device used for drawing and echoing. Currently can only be
either "pdf"
or "png"
.
A logical value indicating whether to perform antialiasing when converting from PDF to PNG.
A numeric value indicating the resolution (dpi) to use when converting from PDF to PNG.
Numeric values indicating the size of the device to test on.
A logical value indicating whether non-identical output should produce a warning or an error.
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.
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.
# NOT RUN {
plotdiff(expression(plot(1)), "plot")
# }
Run the code above in your browser using DataLab