Record a ggplot expression
record_ggplot.Rdrecord_ggplot captures a complete {ggplot2} expression, evaluates it, and
creates a chronicle object. It uses a robust tryCatch and withCallingHandlers
pattern to reliably capture errors, warnings, and messages.
To trigger all conditions, including rendering-time warnings and messages, it
forces a full render of the plot. This is achieved safely by opening a null
graphics device (pdf(NULL)), scheduling its closure with on.exit(dev.off()),
and then printing the plot. This guarantees that the temporary device is always
closed, even if an error occurs, preventing any side effects on the user's
active graphics session.