Skip to contents

Sub-layer stages

Take a snapshot of a layer’s data in the sub-layer pipeline

Workflow functions

These high-level functions take a ggplot object and a function or ggproto method, allowing interactions with the ggplot’s build pipeline as it is evaluated. Functions grouped into three “workflows”: Inspect, Capture, and Highjack.

with_ggtrace()
Generic workflow function which localizes a ggtrace call to a single ggplot object

Inspect workflow

Return values from or information about a method’s execution state for inspection

ggtrace_inspect_n()
Inspect how many times a method was called
ggtrace_inspect_which()
Inspect which calls to a ggproto method met a particular condition
ggtrace_inspect_vars()
Inspect the value of variables from a method
ggtrace_inspect_args()
Inspect the arguments passed into a method
ggtrace_inspect_return()
Inspect the return value of a method
ggtrace_inspect_on_error()
Get information about a ggproto method on error

Capture workflow

Record a method’s execution state, returning it as a function or environment

ggtrace_capture_fn()
Capture a snapshot of a method as a pre-filled function
ggtrace_capture_env()
Capture a snapshot of a method's execution environment

Highjack workflow

Manipulate a method’s behavior as it runs and return the modified graphical output

ggtrace_highjack_args()
Highjack a method's execution and modify its argument values
ggtrace_highjack_return()
Highjack a method's execution and make it return a user-supplied value

Contextualize errors at the layer and sub-layer level

Return information about the (sub-)layer ggproto method that errors while rendering

last_layer_errorcontext() last_sublayer_errorcontext()
Get the internal context of the last (sub-)layer error

Extending base::trace()

The low-level function ggtrace() extends base::trace() by managing the state of injected expressions (traces), which allows for contiguity across multiple traces and the inspection of evaluated expressions logged to the tracedump, via last_ggtrace() and global_ggtrace(). Unlike the high-level workflow functions, ggtrace() relies on the “side effect” of functions and methods being traced, which can be restored with gguntrace().

Trace

Lower-level functions for finer control over injecting expressions with trace

ggtrace()
Insert traces for delayed evaluation
ggedit()
Interactively edit a masking copy of the source code
gguntrace()
Remove any existing traces

Tracedumps

Log and interact with the output of expressions injected with trace

Helpers

Helpers for working with ggtrace

get_method() get_method_inheritance() ggbody() ggformals()
Get information about ggproto methods
is_traced()
Check if a method is being traced

Misc

Extending other debugging tools for use with ggplot internals

ggdebug() ggdebugonce() ggundebug()
Debug a ggproto method