Add a ggplot2 Layer to a pc_interactive Object
pc_add.RdQueues a ggplot2 layer (theme, scale, title, etc.) to be applied to the internal ggplot before it is converted to a plotly widget.
Use pc_add() instead of + when working with ggplot2 >= 4.0.0, because
ggplot2's S7-based + generic intercepts the call before S3 dispatch can
reach +.pc_interactive.
Arguments
- x
A
pc_interactiveobject returned byplot_compare(..., interactive = TRUE).- ...
One or more ggplot2 layer objects (e.g.
ggplot2::ggtitle(),ggplot2::theme(),ggplot2::scale_colour_manual()).
Value
The updated pc_interactive object (invisibly), with layers queued
for application at print / as_plotly() time.
Examples
if (FALSE) { # \dontrun{
p <- plot_compare(res, interactive = TRUE)
p <- pc_add(p, ggplot2::ggtitle("My title"), ggplot2::theme_minimal())
print(p) # converts to plotly with title and theme applied
} # }