Reputation: 1057
I have a set of figures I'm creating to highlight single base mutations. I want the figures to have titles that highlight just the single base change in the codon of interest, i.e. "Stuff (CCC -> CCG)". However, I can't seem to figure out how to create an expression that highlights a single character without adding in flanking spaces (using tilde evaluation). I tried using paste0()
inside expression
with bquote
outside but couldn't seem to get anything that was perfectly functional. Any ideas?
Test plot:
(Slight preference to underlining, which I've used here, but I'd take bold if the promised markdown formatting has been implemented in ggplot, but it looked like it was still in development as of writing.)
ggplot(mtcars, aes(wt, mpg)) +
ggtitle(expression("Stuff (CC"~underline("C")~" -> CC"~underline("G")~")"))
Upvotes: 0
Views: 35
Reputation: 50668
You can concatenate the individual text elements with paste
within expression
ggplot(mtcars, aes(wt, mpg)) +
ggtitle(expression(paste("Stuff (CC", underline("C"), " -> CC", underline("G"), ")")))
Upvotes: 3