Finalize a ggplot for plotly rendering with mathematical axis labels
Source:R/90_utils.R
av_finalize_plotly.RdConverts a ggplot to a plotly object and replaces any expression()
axis labels with their HTML equivalents using an internal lookup table.
This ensures mathematical notation renders correctly in both static (PDF)
and interactive (Shiny/plotly) contexts.
Examples
example_file <- system.file(
"extdata", "bcl11a_rs1427407_example.csv", package = "AlphaVaR"
)
obj <- av_import_csv(example_file) |>
av_calc_enrichment(group_by = "output_type")
#> Reading bcl11a_rs1427407_example.csv ...
p <- av_plot_enrichment(obj, style = "bar")
# plotmath renders correctly in PDF but arrives as literal text in plotly.
p$labels$x
#> expression(-log[10](p[adj]))
pp <- av_finalize_plotly(p)
plotly::plotly_build(pp)$x$layout$xaxis$title$text
#> [1] "-log<sub>10</sub>(p<sub>adj</sub>)"