r - Using different font styles in annotate (ggplot2) -


i'm using code below generate simple chart annotations:

require(ggplot2); data(mtcars) ggplot(mtcars, aes(x = wt, y = mpg)) +    geom_point() +   annotate("text", x = 4, y = 25, label = "this should bold\nand not",            colour = "red") +   geom_vline(xintercept = 3.2, colour = "red") 

simple plot

on chart apply bold font first part of phrase in text annotation:

this should bold

but wish remaining part of text remain unaltered respect font face , style.

how using plotmath syntax parse = true:

ggplot(mtcars, aes(x = wt, y = mpg)) +      geom_point() +     annotate("text", x = 4, y = 25,              label = 'atop(bold("this should bold"),"this should not")',             colour = "red", parse = true) +     geom_vline(xintercept = 3.2, colour = "red") 

enter image description here


Comments

Popular posts from this blog

c# - How can I have the VS Debugger break in the correct location for exceptions thrown in Async methods in a Console App? -

c# - Why Does .NET 4.6 Specific Code Compile When Targeting Older Versions of the Framework? -

php - Issues outputting data after prepared statement with loops -