if (FALSE) { # require("ggiraph", quietly = TRUE, character.only = TRUE)
library(ggplot2)
library(flextable)
library(ggiraph)
library(gdtools)
font_set_liberation()
flextable::set_flextable_defaults(
font.size = 12,
font.family = "Liberation Sans"
)
# Caption with subscript (H2O)
p <- ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
theme_minimal(base_family = "Liberation Sans") +
theme(
plot.caption = element_chunks(
as_paragraph(
as_chunk("Chemical formula: "),
as_chunk("H"),
as_sub("2"),
as_chunk("O")
)
)
)
x <- girafe(
ggobj = p,
options = list(opts_sizing(rescale = FALSE)),
dependencies = list(
liberationsansHtmlDependency()
)
)
x
# Title with superscript
p <- ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
theme_minimal(base_family = "Liberation Sans") +
theme(
plot.title = element_chunks(
as_paragraph(
as_chunk("Model fit: R"),
as_sup("2"),
as_chunk(" = 0.87")
)
)
)
x <- girafe(
ggobj = p,
options = list(opts_sizing(rescale = FALSE)),
dependencies = list(
liberationsansHtmlDependency()
)
)
x
}
Run the code above in your browser using DataLab