plotly::ggplotly() drops ggplot captions (and subtitles). This helper
re-adds the caption as a small grey annotation below the plot area (bottom
left, under the x-axis title) and widens the bottom margin accordingly.
\n line breaks are converted to <br />.
Arguments
- pl
A plotly object as returned by
plotly::ggplotly().- caption
Character. The caption text;
NULLor""returnsplunchanged.- font_size
Numeric. Caption font size in px. Default 10.
Details
Used by the vignettes together with cost_rates_caption() so the
interactive cost plots name the unit-cost rates they were computed with.
Examples
if (FALSE) { # \dontrun{
pl <- plotly::ggplotly(p, tooltip = "text")
pl <- plotly_add_caption(pl, cost_rates_caption("de"))
} # }