Learn R Programming

tinyplot (version 0.8.0)

restore_plot_region: Restore the original plot region

Description

A theme applies its margins through the before.plot.new hook, so they live in the current graphics state but never reach par(). Rolling an ephemeral theme back therefore leaves par(plt) describing a different region than the one we just drew into. Base R recomputes the device clipping rectangle from par(), but only when xpd changes, so anything added afterwards gets silently truncated to the wrong rectangle as soon as some intervening call touches xpd (e.g. box(), mtext(), or type_text(xpd = NA)). See #629.

Fix: put the original (drawn-into) region back, then hand mar_before back at the next plot.new() so the theme's margins don't leak into the following plot.

Usage

restore_plot_region(mar_before)

Value

NULL (called for side effect of resetting par("plt"))

Arguments

mar_before

Pre-theme inner margins (from par("mar"))