Convert a pc_interactive Object to a Plotly Widget
as_plotly.RdConverts a plot_compare() pc_interactive result to a
plotly::plotly htmlwidget, applying the hover-band JavaScript for
dotplots. Useful in knitr/Quarto documents where the object should be
the direct return value of the chunk so that knitr embeds it correctly.
Arguments
- x
A
pc_interactiveobject returned byplot_compare(..., interactive = TRUE).- height
Numeric or
NULL. Widget height in pixels passed toplotly::ggplotly().NULL(default) lets plotly choose its own default height (~400 px), which is often too short when the plot has multiple facet panels each showing many varieties. A sensible rule of thumb: 180 px per panel row (e.g.height = 700for 4 panels in a 2 x 2 grid).- width
Numeric or
NULL. Widget width in pixels.NULL(default) uses 100 % of the container width.- ...
Unused; included for future extensibility.
Value
A plotly::plotly htmlwidget.
Examples
if (FALSE) { # \dontrun{
# Single-group dotplot -- default height is fine
as_plotly(plot_compare(res, type = "dotplot", interactive = TRUE))
# Four-panel dotplot -- set a taller height so panels don't overlap
as_plotly(plot_compare(res, type = "dotplot", interactive = TRUE),
height = 700)
} # }