Closed sjlussier closed 7 months ago
The syntax is (and has always been):
library(ggplot)
library(ggtext)
mtcars %>%
ggplot(aes(x = wt, y = log2(mpg))) +
geom_point() +
scale_y_continuous(labels = glue("2<sup>{1:6}</sup>"), breaks=1:6, limits = c(1, 6)) +
theme(axis.text.y = ggtext::element_markdown())
Thanks for the quick reply! Interestingly, the syntax that I posted had worked previously -- but a very easy fix to change it as you suggested.
If it worked previously but now no longer then that's probably due to changes in the markdown package. You could file a report there.
> markdown::markdownToHTML("2^4", options = c("use_xhtml", "fragment_only"))
[1] "<p>2^4</p>\n"
Unfortunately markdown is not a standardized formatting language and different markdown-to-HTML converters accept different syntax or sometimes change syntax over time.
The most recent version of ggtext appears to no longer render superscript text as it functioned previously. Here is an example:
library(ggplot2) library(ggtext)
mtcars %>% ggplot(aes(x = wt, y = log2(mpg))) + geom_point() + scale_y_continuous(labels = glue("2^{1:6}"), breaks=1:6, limits = c(1, 6)) + theme(axis.text.y = ggtext::element_markdown())